South Africa's first black president spent nearly a third of his life as a prisoner of apartheid, yet he sought to win over its defeated guardians in a relatively peaceful transition of power that inspired the world.
As head of state, the former boxer, lawyer and inmate lunched with the prosecutor who argued successfully for his incarceration; he sang the apartheid-era Afrikaans anthem at his inauguration and travelled hundreds of miles to have tea with the widow of the prime minister who was in power at the time he was sent to prison.
It was this generosity of spirit that made Mr Mandela, who died yesterday at the age of 95, a global symbol of sacrifice and reconciliation in a world often jarred by conflict and division.
His stature as a fighter against apartheid - the system of white racist rule he called evil - and a seeker of peace with his enemies was on a par with that of other men he admired - American civil rights activist Martin Luther King and Indian independence leader Mohandas Gandhi, both of whom were assassinated while actively engaged in their callings.
Dressed in black, South African president Jacob Zuma announced on TV that Mr Mandela died "peacefully", surrounded by family, at around 8.50pm.
At times, Mr Mandela embraced his iconic status, appearing before a rapturous crowd at Wembley Stadium soon after his 1990 release from prison. Sometimes, he sought to downplay it, uneasy about the perils of being put on a pedestal.
In court, he described himself as "the loneliest man" during his mid-1990s divorce from Winnie Mandela.
As president, he could not forge lasting solutions to poverty, unemployment and other social ills that still plague today's South Africa, which has struggled to live up to its rosy depiction as the "Rainbow Nation". But he secured near-mythical status in his country and beyond.
South Africa erected statues and named buildings and other places after him. He shared the 1993 Nobel Peace Prize with FW de Klerk, the country's last white president. He was the subject of books, films and songs and a magnet for celebrities.
His last public appearance was in In 2010, when he waved to the crowd at the Soccer City stadium at the closing ceremony of the World Cup, whose staging in South Africa allowed the country, and the continent, to shine internationally.
In the 1950s, Mr Mandela sought universal rights through peaceful means but was sentenced to life imprisonment in 1964 for leading a campaign of sabotage against the government. The speech he gave during that trial outlined his vision and resolve.
"During my lifetime I have dedicated myself to this struggle of the African people," he said. "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. It is an ideal which I hope to live for and to achieve. But if needs be, it is an ideal for which I am prepared to die."
He was confined to the harsh Robben Island prison near Cape Town for most of his time behind bars, then moved to jails on the mainland. It was forbidden to quote him or publish his photo, yet he and other jailed members of his banned African National Congress were able to smuggle out messages of guidance and in the final stages of his confinement, he negotiated secretly with the apartheid leaders who recognised change was inevitable.
Thousands died, or were tortured or imprisoned in the decades-long struggle against apartheid, which deprived the black majority of the vote, the right to choose where to live and travel, and other basic freedoms.
So when inmate No 46664 went free after 27 years, walking hand-in-hand with then wife, Winnie out of a prison on the South African mainland, people worldwide rejoiced.
Life, however, imposed new challenges on Mr Mandela.
South Africa's white rulers had portrayed him as the spearhead of a communist revolution and insisted that black majority rule would usher in bloody chaos. Thousands died in factional fighting in the run-up to democratic elections in 1994 and Mr Mandela accused the government of collusion in the bloodshed. But voting day passed peacefully, as did Mr Mandela's inauguration as president
"Never, never and never again shall it be that this beautiful land will again experience the oppression of one by another and suffer the indignity of being the skunk of the world," the new president said. "Let freedom reign. The sun shall never set on so glorious a human achievement! God bless Africa! Thank you."
Since apartheid ended, South Africa has held four parliamentary elections and elected three presidents, always peacefully, setting an example on a continent where democracy is still new and fragile. However, corruption scandals and other missteps under the ruling African National Congress, the liberation group once led by Mr Mandela, have undercut some of the early promise.
Nelson Rolihlahla Mandela was born on July 18 1918, the son of a tribal chief in Transkei, a Xhosa homeland that later became one of the "Bantustans" set up as independent republics by the apartheid regime to cement the separation of whites and blacks.
His royal upbringing gave him a regal bearing that became his hallmark. Many South Africans of all races would later call him by his clan name, Madiba, as a token of affection and respect.
Growing up at a time when virtually all of Africa was under European colonial rule, Mr Mandela attended Methodist schools before being admitted to the black University of Fort Hare in 1938. He was expelled two years later for his role in a student strike.
He moved to Johannesburg and worked as a policeman at a gold mine, boxed as an amateur heavyweight and studied law.
His first wife, nurse Evelyn Mase, bore him four children. A daughter died in infancy, a son was killed in a car crash in 1970 and another son died of Aids in 2005. The couple divorced in 1957 and Evelyn died in 2004.
Mr Mandela began his rise through the anti-apartheid movement in 1944, when he helped form the ANC Youth League.
He organised a campaign in 1952 to encourage defiance of laws that segregated schools, marriage, housing and job opportunities. The government retaliated by barring him from attending gatherings and leaving Johannesburg, the first of many "banning" orders he was to endure.
After a two-day nationwide strike was crushed by police, he and a small group of ANC colleagues decided on military action and Mr Mandela pushed to form the movement's guerrilla wing, Umkhonto we Sizwe, or Spear of the Nation.
He was arrested in 1962 and sentenced to five years' hard labour for leaving the country illegally and inciting blacks to strike.
A year later police uncovered the ANC's underground headquarters on a farm near Johannesburg and seized documents outlining plans for a guerrilla campaign. At a time when African colonies were one by one becoming independent states, Mr Mandela and seven co-defendants were sentenced to life in prison.
The ANC's armed wing was later involved in a series of high-profile bombings that killed civilians and many in the white minority viewed the imprisoned Mr Mandela as a terrorist. The apartheid government, meanwhile, was denounced globally for its campaign of beatings, assassinations and other violent attacks on opponents.
Mr Mandela turned down conditional offers of freedom during his decades in prison. In 1989 PW Botha, South Africa's hardline president, was replaced by Mr de Klerk, who recognised apartheid's end was near.
Talks got under way, with Mr Mandela being spirited out of prison to meet white government leaders. After his release, he took charge of the ANC and was elected president in a landslide in South Africa's first all-race election.
Perceived successes during his tenure include the introduction of a constitution with robust protections for individual rights, and the Truth and Reconciliation Commission, which he established with fellow Nobel laureate Archbishop Desmond Tutu.
Despite his saintly image, Mr Mandela was sometimes a harsh critic. When black journalists mildly criticised his government, he painted them as stooges of the whites who owned the media and some whites with complaints were dismissed as pining for their old privileges.
In the build-up to the Iraq War, Mr Mandela harshly rebuked President George Bush, asking: "Why is the United States behaving so arrogantly? All that (Bush) wants is Iraqi oil."
He suggested Mr Bush and then British prime minister Tony Blair were racists and claimed America, "which has committed unspeakable atrocities in the world", had no moral standing. Until Mr Bush repealed the order in 2008, Mr Mandela could not visit the US without the secretary of state certifying that he was not a terrorist.
Mr Mandela's final years were marked by frequent hospital stays as he struggled with respiratory problems that had bothered him since he contracted tuberculosis in prison.
He stayed in his rural home in Qunu in Eastern Cape province, where Hillary Clinton, then US secretary of state, visited him in 2012, but then moved full-time to his home in Johannesburg so he could be close to medical care in Pretoria, the capital.
His three surviving children are daughter Makaziwe by his first marriage, and daughters Zindzi and Zenani by his second.