The son of a wealthy landowner, Fidel Castro turned his back on a life of privilege to lead a left-wing revolution in Cuba that endured for decades and was shaped by his political cunning, keen sense of destiny and boundless ego.
Castro, who has died at the age of 90, was at once idealistic and pragmatic, sharply intelligent and reckless, charismatic and intolerant.
Critics saw in him a stubborn bully who violated human rights, jailed his critics, banned opposition parties and wrecked Cuba's economy.
Admirers saw a visionary who stood up to U.S. domination of Latin America, brought healthcare and education to the poor, and inspired socialist movements across the world.
Even before leading the 1959 revolution that propelled Cuba toward communism and onto the Cold War stage, Castro saw greatness in himself.
From an early age, he admired history's boldest figures, particularly Alexander the Great, and believed he and his rebels were part of that tradition.
"Men do not shape destiny. Destiny produces the man for the moment," he said in 1959.
Castro toppled the unpopular U.S.-backed dictator Fulgencio Batista by uniting a disparate opposition and outsmarting a bigger, better-equipped Cuban military.
His alliance with the Soviet Union put him at the center of the Cold War, most notably when the 1962 Cuban Missile Crisis took the world to the brink of nuclear war.
He was a global celebrity, his beard, military fatigues and big Cuban cigars making him instantly recognizable.
He owed his prominence in part to geography. Looking to bolster an ally just 90 miles (140 km) from Florida, Moscow helped him build socialism by giving him billions of dollars worth of aid and favorable trade, from oil to tractor parts.
But Castro also mined Cuban nationalism and Latin American pride, stirring resentment of U.S. power and influence.
He managed to preserve his revolution despite constant U.S. hostility even when Cuba reeled from the collapse of the Soviet Union in the early 1990s, showing the vigor of a man who intended to die in office.
Instead, almost killed by a serious intestinal illness, he was forced to step aside in 2006 and he formally handed over to his younger brother, Raul Castro, in 2008.
In his final years, Castro wrote opinion columns for Cuba's state media but was rarely seen. His famously long speeches gave way to silence, at least in public, and comfortable track suits replaced the stiff black boots and crisp military attire.
On Dec. 17, 2014, Raul Castro cut a deal to restore diplomatic ties with the United States. But Fidel Castro offered only lukewarm support, reluctant to back an end of hostilities with his most bitter enemy.
Known by the militaristic title of "El Comandante," in some ways Castro was always replaying the exhilaration of revolt, exhorting Cubans to fight one battle after another, from confronting U.S. hostility to boosting potato production.
He survived numerous assassination attempts and outlasted nine U.S. presidents in power, seizing control of Cuba while Dwight Eisenhower occupied the White House and stepping down during George W. Bush's second term.
Throughout, Castro lectured Cubans.
A magnificent orator who instinctively altered his cadence to fit the moment, he re-trod history and delved deep into detail about Cuban independence heroes, plans to "perfect" the revolution and the declared evils of U.S. imperialism.
Tall and physically commanding, fastidious in his attire, he often built to a crescendo of indignation, gesturing firmly with long-fingered, well-manicured hands.
"We shall endeavor to be brief," he told the United Nations General Assembly in 1960, then set a record for U.N. speeches by talking for nearly 4-1/2 hours.
Castro never allowed statues of him to be erected or streets to be named after him, saying he did not want a cult of personality. Nevertheless, the cult was everywhere. His image and words were posted on billboards and his name was invoked at every public event.
Most Cubans, whether for or against him, refer to him simply as "Fidel."
But many Cubans fled his rule as he expropriated businesses and homes and imposed state control over the economy.
The long arm of Castro's government reached deep into Cubans' lives and internal dissent was stifled with the assiduous harassment and jailing of opponents who Castro described as mercenaries working for the United States.
Economic and political freedoms were constrained and the state controlled everything from the media and ballet companies to doctors' associations and neighborhood watch groups.
The rapprochement with the United States over the last two years has eased tensions but, given the decades of outright animosity, some Cuban-American groups and political leaders openly rejoiced at Castro's death.
Castro was a night owl. He would keep foreign guests waiting until late at night and then summon them for talks. Even his critics would sometimes find themselves oddly charmed by such encounters.
Tad Szulc, a biographer, called him "Cuba's great master of political seduction."
Born on Aug. 13, 1926, Castro grew up as a privileged son on his father's plantation in the eastern village of Biran, where his playmates were children of impoverished workers living in thatched huts with dirt floors. He said the economic injustice he witnessed there inspired a lifelong sympathy for the poor.
He attended the Jesuit-run Belen School in the capital and then studied law at the University of Havana, plunging into the violent politics of the time and starting his drift leftward.
Long-winded, intolerant and – unusually for a Cuban - awkward on the dance floor, he was not embraced by his fellow students at first but eventually emerged as a leader.
He took part in an aborted 1947 plan to overthrow Dominican Republic dictator Rafael Leonidas Trujillo and was at a youth conference in Colombia when riots broke out and some 2,000 people died.
After law school, he decided to run for Congress in 1952. When Batista staged a coup and halted the elections, Castro began plotting armed rebellion.
In 1953, he led a raid on the Moncada barracks in the eastern city of Santiago de Cuba. Dozens of followers died and he, Raul Castro and others were captured and imprisoned.
"History will absolve me," he declared at his trial.
Pardoned in 1955, he went into exile in Mexico where he met Argentine revolutionary Ernesto "Che" Guevara. Together with Raul, they trained a rebel band that in 1956 returned to Cuba aboard an overcrowded yacht called Granma.
Ambushed at landing by government troops, only 12 of the 82 rebels on board made it to the rugged Sierra Maestra mountains.
Castro denied Batista's claims that he was a communist but decades later he told Spanish journalist Ignacio Ramonet in a book "100 hours with Fidel" that by 1952, "I was already a convinced Marxist-Leninist."
Whatever the evolution of his views on communism, he was determined to throw off American influence in Cuba. When U.S.-supplied aircraft bombed his rebels in 1958, he vowed revenge.
"I have sworn that the Americans will pay very dearly for what they are doing," he said in a letter to close friend and aide Celia Sanchez. "When this war has ended, a much bigger and greater war will start for me, a war I shall launch against them. I realize that this will be my true destiny."
Washington viewed him as a potential enemy even before his rebel army forced Batista to flee Cuba on New Year's Day, 1959.
It took just two years for the relationship to unravel as Castro nationalized swaths of the economy and introduced a broad agrarian reform. Thousands escaped the island, starting what became a bitter bulwark of opposition in Florida.
In April 1961, when his military crushed a CIA-backed invasion by Cuban exiles at the Bay of Pigs, he declared Cuba socialist and allied himself with the Soviet Union.
Moscow put nuclear missiles on the island in 1962, touching off a 13-day superpower showdown known as the Cuban Missile Crisis.
In an Oct. 26 cable to Soviet leader Nikita Khrushchev, Castro seemed convinced the Americans would invade Cuba and suggested the Soviets "eliminate this danger" with an act of "legitimate self defense."
Khrushchev felt Castro was advocating a pre-emptive nuclear strike and rejected it, telling him he was satisfied with U.S. President John F. Kennedy's pledge not to invade.
The Soviets withdrew the missiles and Washington secretly agreed to remove its nuclear missiles from Turkey, ending the crisis.
The United States imposed its trade embargo on Cuba in 1962 and the CIA admitted trying to kill Castro in the early years of his rule.
Plots or plot ideas included trying to get Castro to smoke a poisoned cigar and taking advantage of his love of diving with an exploding seashell, or poisoning a diving suit.
Castro reveled in his status as an elusive target.
"I'm really happy to reach 80. I never expected it, not least having a neighbor - the greatest power in the world - trying to kill me every day," he said at a 2006 summit in Argentina, where crowds greeted him like a rock star.
While the embargo was economically devastating, it allowed Castro to shift blame for chronic economic problems away from the system he built and onto the United States.
He cast the fight as a David-and-Goliath story.
Philip Bonsal, U.S. ambassador to Cuba in 1959, later described Castro as a "phenomenally gifted, erratic and unscrupulous autocrat who 'freed his country from American imperialism' only to reduce it to a satellite of Moscow."
In a country that was prosperous by Latin American standards but riven by inequality and illiteracy and with an unsavory reputation as a brothel and gambling-rich playground for Americans, Castro sought to build a socialist society.
His government trained thousands of doctors and provided free schooling, changes that have endured well into the 21st century, even as the state's role in the economy was reduced in recent years.
The gains came, however, at a considerable cost to personal freedoms.
Throughout, Castro was a mentor to left-wing leaders and a friend to intellectuals such as Nobel laureate Gabriel Garcia Marquez, although others abandoned him in horror.
He helped Marxist guerrillas and revolutionary governments around the world, sending troops to Angola in the 1970s to support a left-wing government over the initial objections of Moscow.
Cuba helped defeat South African insurgents in Angola and win Namibia's independence from South Africa in 1990, adding pressure on the apartheid regime.
After Nelson Mandela was freed from prison in 1990, he repeatedly thanked Castro. The Cuban leader was also a hero to Sandinista rebels who took power in Nicaragua in 1979.
When the Soviet bloc collapsed in 1991, it seemed Castro's communist rule would not survive.
Cubans endured prolonged power cuts and shortages of food and basics such as soap. Ever stubborn, Castro implored them to endure the "special period" for the sake of the revolution.
He undertook some reforms, allowing foreign investment and mass tourism from Canada and Europe, and tapping exile dollars by allowing Cubans more contact with their relatives abroad.
He also let the most disgruntled leave in a chaotic exodus of makeshift boats that forced U.S. President Bill Clinton to agree to more orderly migration.
Castro was quick to see a potential ally in late Venezuelan leader Hugo Chavez and courted him well before he won power. When Chavez took office in 1998, Castro had a new source of cheap oil, providing a huge boost to Cuba's economy.
Little was known about Castro's personal life but even among his fiercest critics, few accused him of using power for personal gain. His tastes tended toward the ascetic.
He lived in a compound in western Havana and had nine children with five women, including five sons with his common-law wife Dalia Soto del Valle, who lived with Castro at the end.
His eldest son, Fidel Castro Diaz-Balart, is a Soviet-trained nuclear scientist from the Cuban leader's only acknowledged marriage. Daughter Alina Fernandez, whose mother was a Havana socialite who Castro had an affair with while underground in the 1950s, escaped from Cuba disguised as a tourist in 1993 and is a vocal critic of her father.
In one of two documentaries about him, U.S. director Oliver Stone suggested to Castro that he was a "caudillo," or Latin American strongman.
Castro, who always prickled at suggestions of cruelty, rejected the term. "I am a kind of spiritual leader," he said.