His death closed the final chapter in South Africa's struggle to cast off apartheid, leaving the world with indelible memories of a man of astonishing grace and good humor. Rock concerts celebrated his birthday. Hollywood stars glorified him on screen. And his regal bearing, graying hair and raspy voice made him instantly recognizable across the globe.
As South Africa's first black president, the ex-boxer, lawyer and prisoner No. 46664 paved the way to racial reconciliation with well-chosen gestures of forgiveness. He lunched with the prosecutor who sent him to jail, sang the apartheid-era Afrikaans anthem at his inauguration, and traveled hundreds of miles to have tea with the widow of Hendrik Verwoerd, the prime minister at the time he was imprisoned.
His most memorable gesture came when he strode onto the field before the 1995 Rugby World Cup final in Johannesburg. When he came on the field in South African colors to congratulate the victorious South African team, he brought the overwhelmingly white crowd of 63,000 to its feet, chanting "Nelson! Nelson! Nelson!"
For he had marched headlong into a bastion of white Afrikanerdom -- the temple of South African rugby -- and made its followers feel they belonged in the new South Africa.
At the same time, Mandela was himself uneasy with the idea of being an icon and he did not escape criticism as an individual and a politician, though much of it was muted by his status as a unassailable symbol of decency and principle. As president, he failed to craft a lasting formula for overcoming South Africa's biggest post-apartheid problems, including one of the world's widest gaps between rich and poor. In his writings, he pondered the heavy cost to his family of his decision to devote himself to the struggle against apartheid.
He had been convicted of treason and sentenced to life imprisonment in 1964 for leading a campaign of sabotage against the government, and sent to the notorious Robben Island prison. 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 to the anti-apartheid crusade.
As time passed -- the "long, lonely, wasted years," as he termed them -- international awareness of apartheid grew more acute. By the time Mandela turned 70 he was the world's most famous political prisoner. Such were his mental reserves, though, that he turned down conditional offers of freedom from his apartheid jailers and even found a way to benefit from confinement.
"People tend to measure themselves by external accomplishments, but jail allows a person to focus on internal ones; such as honesty, sincerity, simplicity, humility, generosity and an absence of variety," Mandela says in one of the many quotations displayed at the Apartheid Museum in Johannesburg. "You learn to look into yourself."
Thousands died, were tortured and were imprisoned in the decades-long struggle against apartheid, so that when Mandela emerged from prison in 1990, smiling and waving to the crowds, the image became an international icon of freedom to rival the fall of the Berlin Wall.
South Africa's white rulers had portrayed Mandela as the spearhead of a communist revolution and insisted that black majority rule would usher in the chaos and bloodshed that had beset many other African countries as they shook off colonial rule.
Yet 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. Its democracy has flaws, and the African National Congress has struggled to deliver on promises. It is a front runner ahead of 2014 elections, but corruption scandals and other missteps have undercut some of the promise of earlier years.
"We have confounded the prophets of doom and achieved a bloodless revolution. We have restored the dignity of every South African," Mandela said shortly before stepping down as president in 1999 at age 80.
Nelson Rolihlahla Mandela was born July 18, 1918, the son of a tribal chief in Transkei, one of the future "Bantustans," independent republics set up by the apartheid regime to cement the separation of whites and blacks.
Mandela's royal upbringing gave him a dignified 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 organized 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 labor 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.
"I do not deny that I planned sabotage," he told the court. "I did not plan it in a spirit of recklessness, nor because I have any love of violence. I planned it as a result of a calm and sober assessment of the political situation that had arisen after years of tyranny, exploitation and oppression of my people by whites."
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. Up until 2008, when President George W. Bush rescinded the order, he could not visit the U.S. without a waiver from the secretary of state certifying he was not a terrorist.
From the late 1960s South Africa gradually became an international pariah, expelled from the U.N., banned from the Olympics. In 1973 Mandela refused a government offer of release on condition he agree to confine himself to his native Transkei. In 1982 he and other top ANC inmates were moved off Robben Island to a mainland prison. Three years later Mandela was again offered freedom, and again he refused unless segregation laws were scrapped and the government negotiated with the ANC.
In 1989, F.W. de Klerk became president. This Afrikaner recognized the end was near for white-ruled South Africa. Mandela, for his part, continued, even in his last weeks in prison, to advocate nationalizing 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 a white Cabinet minister.
On Feb. 11, 1990, inmate No. 46664, who had once been refused permission to leave prison for his mother's funeral, went free and walked hand-in-hand with Winnie, his wife. Blacks across the country erupted in joy -- as did many whites.
Mandela took charge of the ANC, shared the 1993 Nobel Peace Prize with de Klerk and was elected president by a landslide in South Africa's first all-race election the following year.
At his inauguration, he stood hand on heart, saluted by white generals as he sang along to two anthems: the apartheid-era Afrikaans "Die Stem," ("The Voice") and the African "Nkosi Sikelel' iAfrika" ("Lord Bless Africa").
To black South Africans expecting a speedy new deal, Mandela pleaded for patience. The millions denied proper housing, schools and health care under apartheid had expected the revolution to deliver quick fixes, but Mandela recognized he had to embrace free market policies to keep white-dominated big business on his side and attract foreign investment.
For all his saintly image, Mandela had an autocratic streak. When black journalists mildly criticized his government, he painted them as stooges of the whites who owned the media. Whites with complaints were dismissed as pining for their old privileges.
He denounced Bush as a warmonger and the U.S. having "committed unspeakable atrocities in the world." When asked about 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.
With his fellow Nobelist, Archbishop Desmond Tutu, he set up the Truth and Reconciliation Commission, which allowed human rights offenders of all races to admit their crimes publicly in return for lenient treatment. It proved to be a kind of national therapy that would become a model for other countries emerging from prolonged strife.
He increasingly left the governing to Deputy President Thabo Mbeki, who took over when Mandela's term ended in June 1999 and he declined to seek another -- a rarity among African presidents.
"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 was now married to Graca Machel, the widowed former first lady of neighboring Mozambique.
He is survived by Machel; his daughter Makaziwe by his first marriage, and daughters Zindzi and Zenani by his second.
Watch South African President Jacob Zuma announce Mandela's death and honor the leader:
Donna Bryson, former AP bureau chief in Johannesburg, contributed to this report. Marcus Eliason has worked for the AP in South Africa and is now stationed in New York.
Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.