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.