On February 16, 1959, Fidel Castro is sworn in as prime minister of Cuba after leading a guerrilla campaign that forced right-wing dictator Fulgencio Batista into exile. Castro, who became commander in chief of Cuba’s armed forces after Batista was ousted on January 1, replaced the more moderate Miro Cardona as head of the country’s new provisional government.

Castro was born in the Oriente province in eastern Cuba, the son of a Spanish immigrant who had made a fortune building rail systems to transport sugar cane. He became involved in revolutionary politics while a student and in 1947 took part in an abortive attempt by Dominican exiles and Cubans to overthrow Dominican dictator Rafael Trujillo. In the next year, he took part in urban riots in Bogota, Colombia. The most outstanding feature of his politics during the period was his anti-American beliefs; he was not yet an overt Marxist.

In 1951, he ran for a seat in the Cuban House of Representatives as a member of the reformist Ortodoxo Party, but General Batista seized power in a bloodless coup d’etat before the election could be held.

Various groups formed to oppose Batista’s dictatorship, and on July 26, 1953, Castro led some 160 rebels in an attack on the Moncada Barracks in Santiago de Cuba–Cuba’s second largest military base. Castro hoped to seize weapons and announce his revolution from the base radio station, but the barracks were heavily defended, and more than half his men were captured or killed.

Castro was himself arrested and put on trial for conspiring to overthrow the Cuban government. During his trial, he argued that he and his rebels were fighting to restore democracy to Cuba, but he was nonetheless found guilty and sentenced to 15 years in prison.

Two years later, Batista felt confident enough in his power that he granted a general amnesty for all political prisoners, including Castro. Castro then went with his brother Raul to Mexico, and they organized the revolutionary 26th of July Movement, enlisting recruits and joining up with Ernesto “Che” Guevara, an idealist Marxist from Argentina.

On December 2, 1956, Castro and 81 armed men landed on the Cuban coast. All of them were killed or captured except for Castro, Raul, Che, and nine others, who retreated into the Sierra Maestra mountain range to wage a guerrilla war against the Batista government. They were joined by revolutionary volunteers from all over Cuba and won a series of victories over Batista’s demoralized army. Castro was supported by the peasantry, to whom he promised land reform, while Batista received aid from the United States, which bombed suspected revolutionary positions.

By mid-1958, a number of other Cuban groups were also opposing Batista, and the United States ended military aid to his regime. In December, the 26th of July forces under Che Guevara attacked the city of Santa Clara, and Batista’s forces crumbled. Batista fled for the Dominican Republic on January 1, 1959. Castro, who had fewer than 1,000 men left at the time, took control of the Cuban government’s 30,000-man army. The other rebel leaders lacked the popular support the young and charismatic Castro enjoyed, and on February 16 he was sworn in as prime minister.

The United States initially recognized the new Cuban dictator but withdrew its support after Castro launched a program of agrarian reform, nationalized U.S. assets on the island, and declared a Marxist government. Many of Cuba’s wealthier citizens fled to the United States, where they joined the CIA in its efforts to overthrow Castro’s regime.

In April 1961, with training and support by the CIA, the Cuban exiles launched an ill-fated and unsuccessful invasion of Cuba known as the “Bay of Pigs.” The Soviet Union reacted to the attack by escalating its support to Castro’s communist government and in 1962 placed offensive nuclear missiles in Cuba. The discovery of the missiles by U.S. intelligence led to the tense “Cuban Missile Crisis,” which ended after the Soviets agreed to remove the weapons in exchange for a U.S. pledge not to invade Cuba.

Castro’s Cuba was the first communist state in the Western Hemisphere, and he would retain control of it into the 21st century, outlasting 10 U.S. presidents who opposed him with economic embargoes and political rhetoric. After the collapse of the Soviet Union in 1991, Castro lost a valuable source of aid, but he made up for it by courting European and Canadian investment and tourism. In July 2006, Castro temporarily ceded power to his brother Raul after undergoing intestinal surgery. His struggles with illness continued, and he officially stepped down in February 2008. Castro died on November 25, 2016, at 90.

READ MORE: How the Castro Family Dominated Cuba for Nearly 60 Years