Nelson Rolihlahla Mandela was born 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.
Mandela's 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, 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.
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 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, 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 Mandela as a terrorist. The apartheid government, meanwhile, was denounced globally for its campaign of beatings, assassinations and other violent attacks on opponents.
Even in numbing confinement, Mandela sought to flourish.
"Incidentally, you may find that the cell is an ideal place to learn to know yourself, to search realistically and regularly the process of your own mind and feelings," he wrote in 1975 to Winnie Mandela, a prominent activist in her own right who was in a separate jail at that time.
Mandela turned down conditional offers of freedom during his decades in prison. In 1989, PW Botha, South Africa's hard-line president, was replaced by de Klerk, who recognised apartheid's end was near. Mandela continued, even in his last weeks in prison, to advocate nationalising banks, mines and monopoly industries - a stance that frightened the white business community.
But talks were already underway, with 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 Mandela's tenure include the introduction of a constitution with robust protections for individual rights, and the Truth and Reconciliation Commission, which he established with his fellow Nobelist, Archbishop Desmond Tutu. It allowed human rights offenders of all races to admit their crimes publicly in return for lenient treatment. Though not regarded as wholly successful, it proved to be a kind of national therapy that would become a model for other countries emerging from prolonged strife.
Despite his saintly image, 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. Some whites with complaints were dismissed as pining for their old privileges.
In the build-up to the Iraq War, Mandela harshly rebuked President George W. Bush. "Why is the United States behaving so arrogantly?" he asked in a speech. "All that (Bush) wants is Iraqi oil." He suggested 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 Bush repealed the order in 2008, Mandela could not visit the US without the secretary of state certifying that he was not a terrorist.
To critics of his closeness to Fidel Castro and Moammar Gadhafi despite human rights violations in the countries they ruled, Mandela explained that he wouldn't forsake supporters of the anti-apartheid struggle.
To the disappointment of many South Africans, he increasingly left the governing to Deputy President Thabo Mbeki, who won the next presidential election and took over when Mandela's term ended in 1999.
"I must step down while there are one or two people who admire me," Mandela joked at the time. When he retired, he said he was going to stand on a street with a sign that said: "Unemployed, no job. New wife and large family to support."
His marriage to Winnie had fallen apart after his release and he married Graca Machel, the widowed, former first lady of neighbouring Mozambique.
With apartheid vanquished, Mandela turned to peacemaking efforts in other parts of Africa and the world and eventually to fighting AIDS, publicly acknowledging that his own son, Makgatho, had died of the disease.
Mandela's final years were marked by frequent hospitalisations 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.