Fidel Castro ruled Cuba as a one party state for almost half a century.
As communist regimes collapsed across the world, Castro kept the red flag flying right on the doorstep of his greatest enemy, the United States.
A divisive figure his supporters praised him as a champion of socialism, the soldier-politician who had given Cuba back to the people.
But he faced accusations of brutally suppressing opposition and pursuing policies that crippled the Cuban economy.
Fidel Alejandro Castro Ruz was born on 13 August 1926, the illegitimate son of a wealthy farmer, Angel María Bautista Castro y Argiz, who had emigrated to Cuba from Spain
His mother, Lina Ruz González was a farm servant who became his father's mistress, and later, after Fidel's birth, his wife.
Castro attended Catholic schools in Santiago before going on to the Jesuit-run El Colegio de Belen in Havana.
However, he failed to excel academically, preferring to spend his time in sporting activities.
It was while studying law at Havana University in the mid-1940s that he became a political activist, honing his skills as a passionate public speaker.
His targets included the Cuban government, led by the president Ramon Grau, which was mired in accusations of corruption.
Violent protests became the order of the day and Castro found himself targeted by the police.
He also became part of a plot to overthrow Rafael Trujillo, the right-wing leader of the Dominican Republic but the attempt was thwarted after US intervention.
In 1948 Castro married Mirta Diaz-Balart, the daughter of a wealthy Cuban politician. Far from encouraging him to join the country's elite, he turned increasingly to Marxism.
He believed Cuba's economic problems were a result of unbridled capitalism that could only be solved by a people's revolution.
After graduating Castro set up a legal practice but it failed to prosper and he was continually in debt. He remained a political activist, taking part in a series of often violent demonstrations.
In 1952 Fulgencio Batista launched a military coup which overthrew the government of the Cuban president, Carlos Prío.
Batista's policy of closer ties with the United States and the suppression of socialist organisations ran counter to Castro's fundamental political beliefs.
After legal challenges had failed Castro formed an organisation called The Movement, which worked underground in a bid to overthrow the Batista regime.
Cuba had become a haven for the playboy rich, and was run largely by organised crime syndicates. Prostitution, gambling and drug trafficking were endemic.
In July 1953 Castro planned an attack on the Moncada army barracks near Santiago in order to seize weapons for use in an armed uprising.
The attack failed and many revolutionaries were killed or captured. Castro was one of a number of prisoners who went on trial in Sep 1953.
Castro used his court appearance to expose atrocities committed by the army which further raised his profile, particularly among members of the foreign press who were allowed to attend the hearing.
He was sentenced to 15 years in prison. In the event he was released in a general amnesty in May 1955 having served just 19 months in relatively comfortable conditions.
During his short time in prison he divorced his wife and immersed himself in Marxist texts.
As Batista continued to crack down on his opponents, Castro fled to Mexico to avoid being arrested. There he met a young revolutionary named Ernesto "Che" Guevara.
In November 1956 Castro returned to Cuba with 81 armed companions on board a leaking cabin cruiser designed to carry just 12 people.
The party took refuge in the Sierra Maestra mountains. From this base Castro launched a two-year guerrilla campaign against the regime in Havana.
On 2 January, 1959, the rebel army entered the Cuban capital and Batista fled.
Hundreds of Batista's former supporters were executed after trials that many foreign observers deemed as less than fair.
Castro responded by insisting that "revolutionary justice is not based on legal precepts, but on moral conviction".
The new Cuban government promised to give the land back to the people and to defend the rights of the poor.
But the government quickly imposed a one-party system. Hundreds of people were sent to jail and labour camps as political prisoners. Thousands of mainly middle class Cuban's fled into exile.
Castro insisted his ideology was, first and foremost, Cuban.
"There is not communism or Marxism, but representative democracy and social justice in a well-planned economy," he said at the time.
In 1960, Fidel Castro nationalised all US-owned businesses on the island. In response, Washington put Cuba under a trade embargo that was to last into the 21st century.
Castro claimed he was driven into the arms of the Soviet Union and its leader, Nikita Khrushchev, although some commentators say he entered the USSR's embrace willingly.
Whatever the motive, tropical Cuba became a Cold War battleground.
In April 1961, the US attempted to topple the Castro government by recruiting a private army of Cuban exiles to invade the island.
At the Bay of Pigs, Cuban troops repulsed the invaders, killing many and capturing 1,000. Fidel Castro had bloodied the nose of a superpower and it would never forgive him.
A year later, American reconnaissance planes discovered Soviet missiles on their way to sites in Cuba. The world was suddenly staring into the abyss of all-out nuclear war.
"A series of offensive missile sites is now in preparation on that imprisoned island. The purpose of these bases can be none other than to provide a nuclear strike capability against the Western hemisphere," warned President John F Kennedy.
The superpowers stood eyeball to eyeball, but it was President Khrushchev who blinked first, pulling his missiles out of Cuba in return for a secret withdrawal of US weapons from Turkey.
Fidel Castro, though, had become America's enemy number one. The CIA tried to assassinate him, most infamously with Operation Mongoose. Getting him to smoke a cigar packed with explosives was one idea.
Others were even more bizarre, including one to make his beard fall out and make him into a figure to be ridiculed.
The Soviet Union poured money into Cuba. It bought the bulk of the island's sugar harvest and in return its ships crammed into Havana harbour, bringing in desperately needed goods to beat the US trade embargo.
Despite his reliance on the Soviets' help, Castro put Cuba at the head of the newly-emerging Non-Aligned Movement.
However, he also took sides, especially in Africa, sending his troops to support Marxist guerrillas in Angola and Mozambique.
By the mid-1980s, however, global geopolitics were shifting. It was the era of Mikhail Gorbachev, glasnost and perestroika, and it proved catastrophic for Castro's revolution.
Moscow effectively pulled the plug on the Cuban economy by refusing to take its sugar any more.
Still under the US embargo and with its Soviet lifeline cut off, chronic shortages and empty shelves in Cuba were inevitable. Tempers grew shorter as the food queues grew longer.
The country Fidel Castro called the most advanced in the world had, in fact, returned to the age of ox-drawn carts.
By the mid-1990s, many Cubans had had enough. If earlier waves of exiles had been as much about politics as economics, thousands were now taking to the sea in a waterborne exodus to Florida and the dream of a better life. Many drowned but it was a crushing vote of no-confidence in Castro.
Yet Cuba registered some impressive domestic achievements. Good medical care was freely available for all, and Cuba's infant mortality rates compared favourably with the most sophisticated societies on earth.
In later years, Castro seemed to have mellowed. 1998 saw a ground-breaking visit by Pope John Paul II, something which would have been unthinkable even five years earlier.
The then Pope condemned Cuba for its human rights abuses, embarrassing Castro in front of the world's media.
Fidel Castro had created his own unique brand of Caribbean communism which, in his last years, he was forced to adapt, slowly introducing a few free-market reforms to save his revolution.
On 31 July 2006, just days before his 80th birthday, Castro handed over power temporarily to Raul after undergoing emergency intestinal surgery.
His health continued to deteriorate. Early in 2008, Castro announced that he would not accept the positions of president and commander-in chief at the next meeting of the National Assembly.
In a letter published in an official communist newspaper, he was quoted as saying: "It would betray my conscience to take up a responsibility that requires mobility and total devotion, that I am not in a physical condition to offer."
He largely withdrew from public life, writing articles published in the state media under the title Reflections of Comrade Fidel.
He re-emerged in July 2010, he made his first public appearance since falling ill, greeting workers and giving a television interview in which he discussed US tensions with Iran and North Korea.
The following month Castro gave his first speech to the National Assembly in four years, urging the US not to take military action against Iran or North Korea and warning of a nuclear holocaust if tensions increased.
When asked whether Castro may be re-entering government, culture minister Abel Prieto told the BBC: "I think that he has always been in Cuba's political life but he is not in the government. He has been very careful about that. His big battle is international affairs."
President Obama's announcement in December 2014 of the beginning of an end to US trade and other sanctions saw the beginning of a thaw in what had been half a century of hostile relations between the two countries.
Castro welcomed the move stating it was it was "a positive move for establishing peace in the region", but that he mistrusted the US government.
While many Cubans undoubtedly detested Castro, others genuinely loved him. They saw him as a David who could stand up to the Goliath of America, who successfully spat in the "Yanqui" eye.
For them Castro was Cuba and Cuba was Castro.