Sacasa returned from exile in Mexico and, with Mexican aid, established a rival liberal government on Nicaragua's east coast. A civil war erupted between liberal rebels under General Jose Maria Moncada (1868-1945) and the government under Diaz, who requested and received military assistance from the United States. In 1927, US warships arrived and landed some 2,000 Marines and material. Angry at American interference in Nicaraguan affairs, Sandino joined the war, engaging in guerrilla actions against the gringos (white foreigners). US president Calvin Coolidge (1872-1933) sent his personal representative, Henry L. Stimson (1867-1950), to settle the conflict, and Stimson induced the rival leaders, Diaz and Moncada, to disarm and to allow US supervision of forthcoming elections. The liberal Moncada was elected president of Nicaragua on November 4, 1928, but Sandino refused to accept this and continued his guerrilla attacks on Marine detachments. In response, US warplanes bombed the guerrillas' mountain strongholds; fleeing to Mexico, Sandino vowed not to lay down his arms until the removal of the Marines from Nicaragua. In 1932, Sacasa was elected president and attempted to reach an accord with Sandino, who capitulated after the Marines withdrew in 1933. In Mangua in 1934, Sandino was assassinated by national guardsmen angry over teh amnesty given to him by the government.
Violence resumed, however, when former vice president Sacasa returned from exile to claim his rights to the presidency. In April 1927, the United States sent Henry L. Stimson to mediate the civil war. Once in Nicaragua, Stimson began conversations with President Díaz as well as with leaders from both political parties. Stimson's meetings with General José María Moncada, the leader of the liberal rebels, led to a peaceful solution of the crisis. On May 20, 1927, Moncada agreed to a plan in which both sides--the government and Moncada's liberal forces--would disarm. In addition, a nonpartisan military force would be established under United States supervision. This accord was known as the Pact of Espino Negro.
As part of the agreement, President Díaz would finish his term and United States forces would remain in Nicaragua to maintain order and supervise the 1928 elections. A truce between the government and the rebels remained in effect and included the disarmament of both liberal rebels and government troops. Sacasa, who refused to sign the agreement, left the country. United States forces took over the country's military functions, and strengthened the Nicaraguan National Guard.
A rebel liberal group under the leadership of Augusto César Sandino also refused to sign the Pact of Espino Negro. An illegitimate son of a wealthy landowner and a mestizo servant, Sandino had left his father's home early in his youth and traveled to Honduras, Guatemala, and Mexico. During his three-year stay in Tampico, Mexico, Sandino had acquired a strong sense of Nicaraguan nationalism and pride in his mestizo heritage. At the urging of his father, Sandino had returned to Nicaragua in 1926 and settled in the department of Nueva Segovia, where he worked at a gold mine owned by a United States company. Sandino, who lectured the mine workers about social inequalities and the need to change the political system, soon organized his own army, consisting mostly of peasants and workers, and joined the liberals fighting against the conservative regime of Chamorro. Highly distrusted by Moncada, Sandino set up hit-and-run operations against conservative forces independently of Moncada's liberal army. After the United States mediated the agreement between liberal forces and the conservative regime, Sandino, calling Moncada a traitor and denouncing United States intervention, reorganized his forces as the Army for the Defense of Nicaraguan Sovereignty (Ejército Defensor de la Soberanía de Nicaragua-EDSN). Sandino then staged an independent guerrilla campaign against the government and United States forces. Although Sandino's original intentions were to restore constitutional government under Sacasa, after the Pact of Espino Negro agreement his objective became the defense of Nicaraguan sovereignty against the United States. Receiving his main support from the rural population, Sandino resumed his battle against United States troops. At the height of his guerrilla campaign, Sandino claimed to have some 3,000 soldiers in his army, although official figures estimated the number at only 300. Sandino's guerrilla war caused significant damage in the Caribbean coast and mining regions. After debating whether to continue direct fighting against Sandino's forces, the United States opted to develop the nonpartisan Nicaraguan National Guard to contain internal violence. The National Guard would soon become the most important power in Nicaraguan politics.
The late 1920s and early 1930s saw the growing power of Anastasio "Tacho" Somoza García, a leader who would create a dynasty that ruled Nicaragua for four and a half decades. Moncada won the 1928 presidential elections in one of the most honest elections ever held in Nicaragua. For the 1932 elections, the liberals nominated Juan Bautista Sacasa and the conservatives, Adolfo Díaz. Sacasa won the elections and was installed as president on January 2, 1933. In the United States, popular opposition to the Nicaraguan intervention rose as United States casualty lists grew. Anxious to withdraw from Nicaraguan politics, the United States turned over command of the National Guard to the Nicaraguan government, and United States marines left the country soon thereafter. President Sacasa, under pressure from General Moncada, appointed Somoza García as chief director of the National Guard. Somoza García, a close friend of Moncada and nephew of President Sacasa, had supported the liberal revolt in 1926. Somoza García also enjoyed support from the United States government because of his participation at the 1927 peace conference as one of Stimson's interpreters. Having attended school in Philadelphia and been trained by United States marines, Somoza García, who was fluent in English, had developed friends with military, economic, and political influence in the United States.
After United States troops left Nicaragua in January 1933, the Sacasa government and the National Guard still were threatened by Sandino's EDSN. True to his promise to stop fighting after United States marines had left the country, Sandino agreed to discussions with Sacasa. In February 1934, these negotiations began. During their meetings, Sacasa offered Sandino a general amnesty as well as land and safeguards for him and his guerrilla forces. However, Sandino, who regarded the National Guard as unconstitutional because of its ties to the United States military, insisted on the guard's dissolution. His attitude made him very unpopular with Somoza Garcia and his guards. Without consulting the president, Somoza Garcia gave orders for Sandino's assassination, hoping that this action would help him win the loyalty of senior guard officers. On February 21, 1934, while leaving the presidential palace after a dinner with President Sacasa, Sandino and two of his generals were arrested by National Guard officers acting under Somoza García's instructions. They were then taken to the airfield, executed, and buried in unmarked graves. Despite Sacasa's strong disapproval of Somoza García's action, the Nicaraguan president was too weak to contain the National Guard director. After Sandino's execution, the National Guard launched a ruthless campaign against Sandino's supporters. In less than a month, Sandino's army was totally destroyed.