Guerrilla groups opposed to the Somoza dynasty and inspired by Fidel Castro began training in clandestine camps in the northern mountains of Nicaragua  in the early 1950s and coalesced a decade later when Carlos Fonseca Amador, Silvio Mayorga, and Tomás Borge formed the Frente Sandinista de Liberación Nacional (FSLN).
Carlos Fonseca’s ideas, an inspired combination of Marxism (which he’d experienced firsthand in a trip to Moscow) and the nationalist, anti-imperialist beliefs of Augusto Sandino formed their ideological framework: Sandinismo.
Early Sandinista insurrections in Río Coco and Bocay (1963) and Pancasán (1967) were easily crushed but legitimized the FSLN. As trade unions, student organizations, and private and religious, organizations all threw their weight behind the Sandinista insurgency, Tachito grew more brutal and outraged.
In January 1978, Pedro Joaquín Chamorro, editor of La Prensa and a relentless critic of Somoza, was gunned down in Managua . His death fooled no one. One month later, the largely indigenous population of the Masaya  neighborhood of Monimbó protested for five days until the National Guard responded by massacring hundreds. By May 1979, the guerrillas were ready for the final insurrection, which would last 52 days.
Combat erupted simultaneously around Chinandega , León , and Chichigalpa  in the Pacific, and in the mining triangle in the northeast. At the same time, Sandinista troops began pressing north from the border with Costa Rica . They entered León, capturing the city after a two-day battle. The rest of the nation began a massive general labor strike.
On June 8, 1979, Sandinista soldiers and supporters began marching from Carazo , just south of Managua, into the capital itself. The National Guard responded by shelling Managua. Most of the fighting in Managua took place in the lower-middle-class neighborhoods of Bello Horizonte and El Dorado, where extensive networks of concrete drainage ditches made easy battle trenches. The people tore up the concrete adoquines (paving stones) of the streets and erected barricades with them. The world watched, appalled, as Somoza’s aircraft indiscriminately strafed the capital.
The FSLN captured Matagalpa on July 2, 1979, and the strategic town of Sébaco the day after. The Estelí military barracks—the last and most important one after Managua—fell on July 16. Finally, with complete control of the north, FSLN forces surrounded the capital. Trapped by the Sandinistas and abandoned by the United States, Somoza fled Nicaragua in the predawn hours of July 17.