Nelson Mandela guided South Africa from the shackles of apartheid to multi-racial democracy, as an icon of peace and reconciliation who came to embody the struggle for justice around the world.
Imprisoned for nearly three decades for his fight against white minority rule, Mandela emerged determined to use his prestige and charisma to bring down apartheid while avoiding a civil war.
"The time for the healing of the wounds has come. The moment to bridge the chasms that divide us has come," Mandela said in his acceptance speech on becoming South Africa's first black president in 1994.
"We have, at last, achieved our political emancipation."
In 1993, Mandela was awarded the Nobel Peace Prize, an honour he shared with FW de Klerk, the white Afrikaner leader who freed him from prison three years earlier and negotiated the end of apartheid.
Mandela went on to play a prominent role on the world stage as an advocate of human dignity in the face of challenges ranging from political repression to AIDS.
He formally left public life in June 2004 before his 86th birthday, telling his adoring countrymen: "Don't call me. I'll call you". But he remained one of the world's most revered public figures, combining celebrity sparkle with an unwavering message of freedom, respect and human rights.
Whether defending himself at his own treason trial in 1963 or addressing world leaders years later as a greying elder statesman, he radiated an image of moral rectitude expressed in measured tones, often leavened by a mischievous humour.
"He is at the epicentre of our time, ours in South Africa, and yours, wherever you are," Nadine Gordimer, the South African writer and Nobel Laureate for Literature, once remarked.
Mandela's years behind bars made him the world's most celebrated political prisoner and a leader of mythic stature for millions of black South Africans and other oppressed people far beyond his country's borders.
Charged with capital offences in the 1963 Rivonia Trial, his statement from the dock was his political testimony.
"During my lifetime I have dedicated myself to this struggle of the African people. I have fought against white domination, and I have fought against black domination.
"I have cherished the ideal of a democratic and free society in which all persons live together in harmony and with equal opportunities," he told the court.
"It is an ideal I hope to live for and to achieve. But if needs be, it is an ideal for which I am prepared to die."
Nelson Rolihlahla Mandela was born on July 18 1918, destined to lead as the son of the chief councillor to the paramount chief of the Thembu people in Transkei.
He chose to devote his life to the fight against white domination. He studied at Fort Hare University, an elite black college, but left in 1940 short of completing his studies and became involved with the African National Congress (ANC), founding its Youth League in 1944 with Oliver Tambo and Walter Sisulu.
Mandela worked as a law clerk then became a lawyer who ran one of the few practices that served blacks.
In 1952 he and others were charged for violating the Suppression of Communism Act but their nine-month sentence was suspended for two years.
Mandela was among the first to advocate armed resistance to apartheid, going underground in 1961 to form the ANC's armed wing, Umkhonto we Sizwe, or 'Spear of the Nation' in Zulu.
He left South Africa and travelled the continent and Europe, studying guerrilla warfare and building support for the ANC.
After his return in 1962, Mandela was arrested and sentenced to five years for incitement and illegally leaving the country.
While serving that sentence, he was charged with sabotage and plotting to overthrow the government along with other anti-apartheid leaders in the Rivonia Trial.
Branded a terrorist by his enemies, Mandela was sentenced to life imprisonment in 1964, isolated from millions of his countrymen as they suffered oppression, violence and forced re-settlement under the apartheid regime of racial segregation.
He was incarcerated on Robben Island, a penal colony off Cape Town, where he would spend the next 18 years before being moved to mainland prisons.
He was behind bars when an uprising broke out in the huge township of Soweto in 1976 and when others erupted in violence in the 1980s.
But when the regime realised it was time to negotiate, it was Mandela to whom it turned.
In his later years in prison, he met President PW Botha and his successor Mr de Klerk.
When he was released on February 11 1990, walking away from the Victor Verster prison hand-in-hand with his wife Winnie, the event was watched live by television viewers across the world.
"As I finally walked through those gates ... I felt even at the age of 71 that my life was beginning anew. My 10,000 days of imprisonment were at last over," Mandela wrote of that day.
In the four years following his release thousands of people died in political violence. Most were blacks killed in fighting between ANC supporters and Zulus loyal to Mangosuthu Buthelezi's Inkatha Freedom Party, although right-wing whites also staged violent actions to upset the moves towards democracy.
Mandela prevented a racial explosion after the murder of popular Communist Party leader Chris Hani by a white assassin in 1993, appealing for calm in a national television address.
That same year, he and de Klerk were jointly awarded the Nobel Peace Prize.
Talks between the ANC and the government began in 1991, leading to South Africa's first all-race elections on April 271994.
The run-up to the vote was marred by fighting, including gun battles in Johannesburg townships and virtual war in the Zulu stronghold of KwaZulu Natal.
But Mandela campaigned across the country, enthralling adoring crowds of blacks and wooing whites with assurances that there was a place for them in the new South Africa.
The election result was never in doubt and his inauguration in Pretoria on 10 May 1994 was a celebration of a peoples' freedom.
Mandela made reconciliation the theme of his presidency. He took tea with his former jailers and won over many whites when he donned the jersey of South Africa's national rugby team - once a symbol of white supremacy - at the final of the World Cup in 1995 at Johannesburg's Ellis Park stadium.
The hallmark of Mandela's mission was the Truth and Reconciliation Commission which investigated apartheid crimes on both sides and tried to heal the wounds. It also provided a model for other countries torn by civil strife.
In 1999, Mandela, often criticised for having a woolly grasp of economics, handed over to younger leaders - a voluntary departure from power cited as an example to long-ruling African leaders.
A restful retirement was not on the cards as Mandela shifted his energies to fighting South Africa's AIDS crisis.
He spoke against the stigma surrounding the infection, while successor Thabo Mbeki was accused of failing to comprehend the extent of the crisis.
The fight became personal in early 2005 when Mandela lost his only surviving son to the disease.
But the stress of his long struggle contributed to the break-up of his marriage to equally fierce anti-apartheid campaigner Winnie.
The country shared the pain of their divorce in 1996 before watching his courtship of Graca Machel, widow of Mozambican President Samora Machel, whom he married on his 80th birthday in 1998.
Friends adored "Madiba", the clan name by which he is known. People lauded his humanity, kindness, attention and dignity.
Unable to shake the habits of prison, Mandela rose daily between 4am and 5am to exercise and read. He drank little and was a fervent anti-smoker.
An amateur boxer in his younger days, Mandela often said the discipline and tactics drawn from training helped him to endure prison and the political battles after his release.
However prison and old age took their toll on his health.
Mandela was treated in the 1980s for tuberculosis and later required an operation to repair damage to his eyes as well as treatment for prostate cancer in 2001. His spirit, however, remained strong.
"If cancer wins I will still be the better winner," he told reporters in September of that year. "When I go to the next world, the first thing I will do is look for an ANC office to renew my membership."
Most South Africans are proud of their post-apartheid multi-racial 'Rainbow Nation'.
But Mandela's legacy of tolerance and reconciliation has been threatened in recent years by squabbling between factions in the ANC and social tensions in a country that, despite its political liberation, still suffers great inequalities.
Mandela's last major appearance on the global stage came in 2010 when he donned a fur cap in the South African winter and rode on a golf cart, waving to an exuberant crowd of 90,000 at the soccer World Cup final, one of the biggest events in the country's post-apartheid history.
"I leave it to the public to decide how they should remember me," he said on South African television before his retirement.
"But I should like to be remembered as an ordinary South African who together with others has made his humble contribution."