South Africa's first black president died after years of declining health that had caused him to withdraw from public life.
The death of Mandela will send South Africa deep into mourning and self-reflection 18 years after he led the country from racial apartheid to inclusive democracy.
But his passing will also be keenly felt by people around the world who revered Mandela as one of history's last great statesmen, and a moral paragon comparable with Mohandas Gandhi and Martin Luther King.
It was a transcendent act of forgiveness after spending 27 years in prison, 18 of them on Robben Island, that will assure his place in history. With South Africa facing possible civil war, Mandela sought reconciliation with the white minority to build a new democracy.
He led the African National Congress (ANC) to victory in the country's first multiracial election in 1994. Unlike other African liberation leaders who cling to power, such as Zimbabwe's Robert Mugabe, he then voluntarily stepped down after one term.
Mandela – often affectionately known by his clan name, Madiba – was awarded the Nobel peace prize in 1993.
At his inauguration a year later, the new president said: "Never, never, and never again shall it be that this beautiful land will again experience the oppression of one by another ... the sun shall never set on so glorious a human achievement. Let freedom reign. God bless Africa!"
Born Rolihlahla Dalibhunga in a small village in the Eastern Cape on 18 July 1918, Mandela was given his English name, Nelson, by a teacher at his school.
Mandela joined the ANC in 1943 and became a co-founder of its youth league. In 1952, he started South Africa's first black law firm with his partner, Oliver Tambo. Mandela was a charming, charismatic figure with a passion for boxing – and an eye for women. He once said: "I can't help it if the ladies take note of me. I am not going to protest."
He married his first wife, Evelyn Mase, in 1944. They were divorced in 1957 after having three children. In 1958, he married Winnie Madikizela, who later campaigned to free her husband from jail and became a key figure in the struggle.
When the ANC was banned in 1960, Mandela went underground. After the Sharpeville massacre, in which 69 black protesters were shot dead by police, he took the difficult decision to launch an armed struggle.
He was arrested and eventually charged with sabotage and attempting to violently overthrow the government.
Conducting his own defence in the Rivonia Trial in 1964, he said: "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 escaped the death penalty but was sentenced to life in prison, a huge blow to the ANC that had to regroup to continue the struggle. But unrest grew in townships and international pressure on the apartheid regime slowly tightened.
Finally, in 1990, then president FW de Klerk lifted the ban on the ANC and Mandela was released from prison amid scenes of jubilation witnessed around the world.
In 1992, Mandela divorced Winnie after she was convicted on charges of kidnapping and accessory to assault.
His presidency rode a wave of tremendous global goodwill but was not without its difficulties. After leaving frontline politics in 1999, he admitted he should have moved sooner against the spread of HIV/Aids.
His son died from an Aids-related illness. On his 80th birthday, Mandela married Graça Machel, the widow of the former president of Mozambique. It was his third marriage. In total, he had six children, of whom three daughters survive: Pumla Makaziwe (Maki), Zenani and Zindziswa (Zindzi). He has 17 grandchildren and 14 great-grandchildren.
Mandela was diagnosed with prostate cancer in 2001 and retired from public life, aged 85, to be with his family and enjoy some "quiet reflection". But he remained a beloved and venerated figure with countless buildings, streets and squares named after him. His every move was scrutinised and his health was a constant source of media speculation.
Mandela continued to make occasional appearances at ANC events and attended the inauguration of the current president, Jacob Zuma. His 91st birthday was marked by the first annual "Mandela Day" in his honour.
He was last seen in public at the final of the 2010 World Cup in Johannesburg, a tournament he had helped bring to South Africa for the first time. Early in 2011, he was taken to hospital in a health scare but he recovered and was visited by Michelle Obama and her daughters a few months later.
In January 2012, he was notably missing from the ANC's centenary celebrations due to his frail condition. With other giants of the movement such as Tambo and Walter Sisulu having gone before Mandela, the defining chapter of Africa's oldest liberation movement is now closed.