HAVANA — 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.

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."