Fidel Castro, the Cuban revolutionary leader who built a communist state on the doorstep of the United States and for five decades, defied US efforts to topple him, died on Friday, his younger brother announced to the nation. He was 90.
A towering figure of the second half of the 20th Century, Castro had been in poor health since an intestinal ailment nearly killed him in 2006. He formally ceded power to his younger brother two years later.
Wearing a green military uniform, Cuba's President Raul Castro appeared on state television to announce his brother's death.
"At 10.29 at night, the chief commander of the Cuban revolution, Fidel Castro Ruz, died," he said, without giving a cause of death.
"Ever onward, to victory."
The streets were quiet in Havana, but some residents reacted with sadness to the news, while in Miami, where many exiles from the Communist government live, a large crowd waving Cuban flags cheered, danced and banged on pots and pans, a video on social media showed.
"I am very upset. Whatever you want to say, he is a public figure that the whole world respected and loved," said Havana student Sariel Valdespino.
Castro's remains will be cremated, according to his wishes. His brother said details of his funeral would be given on Saturday.
The bearded Fidel Castro took power in a 1959 revolution and ruled Cuba for 49 years with a mix of charisma and iron will, creating a one-party state and becoming a central figure in the Cold War.
He was demonised by the United States and its allies but admired by many leftists around the world, especially socialist revolutionaries in Latin America and Africa.
"I lament the death of Fidel Castro Ruz, leader of the Cuban revolution and emblematic reference of the 20th Century," Mexican President Enrique Pena Nieto said on Twitter.
Transforming Cuba from a playground for rich Americans into a symbol of resistance to Washington, Castro outlasted nine US presidents in power.
He fended off a CIA-backed invasion at the Bay of Pigs in 1961 as well as countless assassination attempts.
His alliance with Moscow helped trigger the Cuban Missile Crisis in 1962, a 13-day showdown with the United States that brought the world the closest it has been to nuclear war.
Wearing green military fatigues and chomping on cigars for many of his years in power, Castro was famous for long, fist-pounding speeches filled with blistering rhetoric, often aimed at the United States.
At home, he swept away capitalism and won support for bringing schools and hospitals to the poor. But he also created legions of enemies and critics, concentrated among Cuban exiles in Miami who fled his rule and saw him as a ruthless tyrant.
In the end, it was not the efforts of Washington and Cuban exiles nor the collapse of Soviet communism that ended his rule. Instead, illness forced him to cede power to his younger brother Raul Castro, provisionally in 2006 and definitively in 2008.
Although Raul Castro always glorified his older brother, he has changed Cuba since taking over by introducing market-style economic reforms and agreeing with the United States in December 2014 to re-establish diplomatic ties and end decades of hostility.
Six weeks later, Fidel Castro offered only lukewarm support for the deal, raising questions about whether he approved of ending hostilities with his longtime enemy.
He lived to witness the visit of US President Barack Obama to Cuba earlier this year, the first trip by a U.S. president to the island since 1928.
Castro did not meet Obama, and days later wrote a scathing column condemning the US president's "honey-coated" words and reminding Cubans of the many US efforts to overthrow and weaken the Communist government.
In his final years, Fidel Castro no longer held leadership posts. He wrote newspaper commentaries on world affairs and occasionally met with foreign leaders, but he lived in semi-seclusion.
His death - which would once have thrown a question mark over Cuba's future - seems unlikely to trigger a crisis as Raul Castro, 85, is firmly ensconced in power.
Still, the passing of the man known to most Cubans as "El Comandante" - the commander - or simply "Fidel" leaves a huge void in the country he dominated for so long. It also underlines the generational change in Cuba's communist leadership.
Raul Castro vows to step down when his term ends in 2018, and the Communist Party has elevated younger leaders to its Politburo, including 56-year-old Miguel Diaz-Canel, who is first vice-president and the heir apparent.
Others in their 50s include Foreign Minister Bruno Rodriguez and economic reform czar Marino Murillo.
The reforms have led to more private enterprise and the lifting of some restrictions on personal freedoms, but they aim to strengthen Communist Party rule, not weaken it.
"I don't think Fidel's passing is the big test. The big test is handing the revolution over to the next generation, and that will happen when Raul steps down," Cuba expert Phil Peters of the Lexington Institute in Virginia said before Castro's death.
A Jesuit-educated lawyer, Fidel Castro led the revolution that ousted US-backed dictator Fulgencio Batista on Jan 1, 1959. Aged 32, he quickly took control of Cuba and sought to transform it into an egalitarian society.
His government improved the living conditions of the very poor, achieved health and literacy levels on a par with rich countries and rid Cuba of a powerful Mafia presence.
But he also tolerated little dissent, jailed opponents, seized private businesses and monopolised the media.
Castro's opponents labelled him a dictator and hundreds of thousands fled the island.
Many settled in Florida, influencing US policy toward Cuba and plotting Castro's demise. Some even trained in the Florida swamps for the disastrous Bay of Pigs invasion.
But they could never dislodge him.
Generations of Latin American leftists applauded Castro for his socialist policies and for thumbing his nose at the United States from its doorstep just 90 miles (145 km) from Florida.
Castro claimed he survived or evaded hundreds of assassination attempts, including some conjured up by the CIA.
In 1962, the United States imposed a damaging trade embargo that Castro blamed for most of Cuba's ills, using it to his advantage to rally patriotic fury.
Over the years, he expanded his influence by sending Cuban troops into far-away wars, including 350,000 to fight in Africa. They provided critical support to a left-wing government in Angola and contributed to the independence of Namibia in a war that helped end apartheid in South Africa.
He also won friends by sending tens of thousands of Cuban doctors abroad to treat the poor and bringing young people from developing countries to train them as physicians
'HISTORY WILL ABSOLVE ME'
Born on August 13, 1926, in Biran in eastern Cuba, Castro was the son of a Spanish immigrant who became a wealthy landowner.
Angry at social conditions and Batista's dictatorship, Fidel Castro launched his revolution on July 26, 1953, with a failed assault on the Moncada barracks in the eastern city of Santiago.
"History will absolve me," he declared during his trial for the attack.
He was sentenced to 15 years in prison but was released in 1955 after a pardon that would come back to haunt Batista.
Castro went into exile in Mexico and prepared a small rebel army to fight Batista. It included Argentine revolutionary Ernesto "Che" Guevara, who became his comrade-in-arms.
In December 1956, Castro and a rag-tag band of 81 followers sailed to Cuba aboard a badly overloaded yacht called "Granma".
Only 12, including him, his brother and Guevara, escaped a government ambush when they landed in eastern Cuba.
Taking refuge in the rugged Sierra Maestra mountains, they built a guerrilla force of several thousand fighters who, along with urban rebel groups, defeated Batista's military in just over two years.
Early in his rule, at the height of the Cold War, Castro allied Cuba to the Soviet Union, which protected the Caribbean island and was its principal benefactor for three decades.
The alliance brought in $4 billion worth of aid annually, including everything from oil to guns, but also provoked the 1962 Cuban Missile Crisis when the United States discovered Soviet missiles on the island.
Convinced that the United States was about to invade Cuba, Castro urged the Soviets to launch a nuclear attack.
Cooler heads prevailed. Soviet leader Nikita Khrushchev and US President John F. Kennedy agreed the Soviets would withdraw the missiles in return for a US promise never to invade Cuba. The United States also secretly agreed to remove its nuclear missiles from Turkey.
When the Soviet Union collapsed in 1991, an isolated Cuba fell into a deep economic crisis that lasted for years and was known as the "special period". Food, transport and basics such as soap were scarce, and energy shortages led to frequent and long blackouts.
Castro undertook a series of tentative economic reforms to get through the crisis, including opening up to foreign tourism.
The economy improved when Venezuela's socialist leader Hugo Chavez, who looked up to Castro as a hero, came to the rescue with cheap oil. Aid from communist-run China also helped, but an economic downturn in Venezuela since Chavez's death in 2013 have raised fears it will scale back its support for Cuba.
Plagued by chronic economic problems, Cuba's population of 11 million has endured years of hardship, although not the deep poverty, violent crime and government neglect of many other developing countries.
For most Cubans, Fidel Castro has been the ubiquitous figure of their entire life.
Many still love him and share his faith in a communist future, and even some who abandoned their political belief still view him with respect. But others see him as an autocrat and feel he drove the country to ruin.
Cubans earn on average the equivalent of $20 a month and struggle to make ends meet even in an economy where education and health care are free, and many basic goods and services are heavily subsidised.
It was never clear whether Fidel Castro fully backed his brother's reform efforts of recent years. Some analysts believed his mere presence kept Raul from moving further and faster while others saw him as either quietly supportive or increasingly irrelevant.