Former President Fidel Castro, who led a rebel army to improbable victory in Cuba, embraced Soviet-style communism and defied the power of 10 U.S. presidents during his half-century rule, has died at age 90.

Castro’s reign over the island-nation 90 miles from Florida was marked by the U.S.-backed Bay of Pigs invasion in 1961 and the Cuban Missile Crisis a year later that brought the world to the brink of nuclear war. The bearded revolutionary, who survived a crippling U.S. trade embargo as well as dozens, possibly hundreds, of assassination plots, died eight years after ill health forced him to formally hand power over to his younger brother Raul, who announced his death late Friday on state television.

Castro overcame imprisonment at the hands of dictator Fulgencio Batista, exile in Mexico and a disastrous start to his rebellion before triumphantly riding into Havana in January 1959 to become, at age 32, the youngest leader in Latin America. For decades, he served as an inspiration and source of support to revolutionaries from Latin America to Africa.

His commitment to socialism was unwavering, though his power finally began to fade in mid-2006 when a gastrointestinal ailment forced him to hand over the presidency to Raul in 2008, provisionally at first and then permanently. His defiant image lingered long after he gave up his trademark Cohiba cigars for health reasons and his tall frame grew stooped.

“Socialism or death” remained Castro’s rallying cry even as Western-style democracy swept the globe and other communist regimes in China and Vietnam embraced capitalism, leaving this island of 11 million people an economically crippled Marxist curiosity.

He survived long enough to see Raul Castro negotiate an opening with U.S. President Barack Obama on Dec. 17, 2014, when Washington and Havana announced they would move to restore diplomatic ties for the first time since they were severed in 1961. He cautiously blessed the historic deal with his lifelong enemy in a letter published after a month-long silence.

Fidel Castro Ruz was born Aug. 13, 1926, in eastern Cuba’s sugar country, where his Spanish immigrant father worked first recruiting labor for U.S. sugar companies and later built up a prosperous plantation of his own.

Castro attended Jesuit schools, then the University of Havana, where he received law and social science degrees. His life as a rebel began in 1953 with a reckless attack on the Moncada military barracks in the eastern city of Santiago. Most of his comrades were killed and Fidel and his brother Raul went to prison.

Fidel turned his trial defense into a manifesto that he smuggled out of jail, famously declaring, “History will absolve me.”

Freed under a pardon, Castro fled to Mexico and organized a rebel band that returned in 1956, sailing across the Gulf of Mexico to Cuba on a yacht named Granma. After losing most of his group in a bungled landing, he rallied support in Cuba’s eastern Sierra Maestra mountains.

Three years later, tens of thousands spilled into the streets of Havana to celebrate Batista’s downfall and catch a glimpse of Castro as his rebel caravan arrived in the capital on Jan. 8, 1959.

The U.S. was among the first to formally recognize his government, cautiously trusting Castro’s early assurances he merely wanted to restore democracy, not install socialism.

Within months, Castro was imposing radical economic reforms. Members of the old government went before summary courts, and at least 582 were shot by firing squads over two years. Independent newspapers were closed and in the early years, homosexuals were herded into camps for “re-education.”

In 1964, Castro acknowledged holding 15,000 political prisoners. Hundreds of thousands of Cubans fled, including Castro’s daughter Alina Fernandez Revuelta and his younger sister Juana.

Still, the revolution thrilled millions in Cuba and across Latin America who saw it as an example of how the seemingly arrogant Yankees could be defied. And many on the island were happy to see the seizure of property of the landed class, the expulsion of American gangsters and the closure of their casinos.

Castro’s speeches, lasting up to six hours, became the soundtrack of Cuban life and his 269-minute speech to the U.N. General Assembly in 1960 set the world body’s record for length that still stood more than five decades later.

As Castro moved into the Soviet bloc, Washington began working to oust him, cutting U.S. purchases of sugar, the island’s economic mainstay. Castro, in turn, confiscated $1 billion in U.S. assets.

The American government imposed a trade embargo, banning virtually all U.S. exports to the island except for food and medicine, and it severed diplomatic ties on Jan. 3, 1961.

On April 16 of that year, Castro declared his revolution to be socialist, and the next day, about 1,400 Cuban exiles stormed the beach at the Bay of Pigs on Cuba’s south coast. But the CIA-backed invasion failed.

The debacle forced the U.S. to give up on the idea of invading Cuba, but that didn’t stop Washington and Castro’s exiled enemies from trying to do him in. By Cuban count, he was the target of more than 630 assassination plots by militant Cuban exiles or the U.S. government.

The biggest crisis of the Cold War between Washington and Moscow exploded on Oct. 22, 1962, when President John F. Kennedy announced there were Soviet nuclear missiles in Cuba and imposed a naval blockade of the island. Humankind held its breath, and after a tense week of diplomacy, Soviet leader Nikita Krushchev removed them. Never had the world felt so close to nuclear war.

Castro cobbled revolutionary groups together into the new Cuban Communist Party, with him as first secretary. Labor unions lost the right to strike. The Catholic Church and other religious institutions were harassed. Neighborhood “revolutionary defense committees” kept an eye on everyone.

Castro exported revolution to Latin American countries in the 1960s, and dispatched Cuban troops to Africa to fight Western-backed regimes in the 1970s. Over the decades, he sent Cuban doctors abroad to tend to the poor, and gave sanctuary to fugitive Black Panther leaders from the U.S.

But the collapse of the Soviet bloc ended billions in preferential trade and subsidies for Cuba, sending its economy into a tailspin. Castro briefly experimented with an opening to foreign capitalists and limited private enterprise.

As the end of the Cold War eased global tensions, many Latin American and European countries re-established relations with Cuba. In January 1998, Pope John Paul II visited a nation that had been officially atheist until the early 1990s.

Aided by a tourism boom, the economy slowly recovered and Castro steadily reasserted government control, stifling much of the limited free enterprise tolerated during harder times.

As flamboyant as he was in public, Castro tried to lead a discreet private life. He and his first wife, Mirta Diaz Balart, had one son before divorcing in 1956. Then, for more than four decades, Castro had a relationship with Dalia Soto del Valle. They had five sons together and were said to have married quietly in 1980.

By the time Castro resigned 49 years after his triumphant arrival in Havana, he was the world’s longest ruling head of government, aside from monarchs.

In retirement, Castro voiced unwavering support as Raul slowly but deliberately enacted sweeping changes to the Marxist system he had built.

His longevity allowed the younger brother to consolidate control, perhaps lengthening the revolution well past both men’s lives. In February 2013, Raul announced that he would retire as president in 2018 and named newly minted Vice President Miguel Diaz-Canel as his successor.

“I’ll be 90 years old soon,” Castro said at an April 2016 communist party congress where he made his most extensive public appearance in years. “Soon I’ll be like all the others. The time will come for all of us, but the ideas of the Cuban Communists will remain as proof that on this planet, if one works with fervor and dignity, they can produce the material and cultural goods that human beings need and that need to be fought for without ever giving up.”
___
Associated Press writer Michael Weissenstein reported this story in Havana and Peter Orsi reported from Mexico City. AP writer Anita Snow in Mexico City and AP news researcher Rhonda Shafner in New York contributed to this report.