Mandela, who was elected South Africa’s first black president after spending nearly three decades in prison, had been receiving treatment for a lung infection at his Johannesburg home since September, after three months in hospital in a critical state.
His condition deteriorated and he died following complications from the lung infection, with his family by his side.
The news was announced by a clearly emotional South African president Jacob Zuma live on television, who said Mandela had “departed” and was at peace.
“Our nation has lost its greatest son,” said Zuma.
“What made Nelson Mandela great is precisely what made him human,” he said.
Mandela, once a boxer, had a long history of lung problems after contracting tuberculosis while in jail on Robben Island.
His extraordinary life story, quirky sense of humour and lack of bitterness towards his former oppressors ensured global appeal for the charismatic leader.
Once considered a terrorist by the United States and Britain for his support of violence against the apartheid regime, at the time of his death he was an almost unimpeachable moral icon.
The Nobel Peace Prize winner spent 27 years behind bars before being freed in 1990 to lead the African National Congress (ANC) in negotiations with the white minority rulers which culminated in the first multi-racial elections in 1994.
A victorious Mandela served a single term as president before taking up a new role as a roving elder statesman and leading AIDS campaigner before finally retiring from public life in 2004.
“When he emerged from prison people discovered that he was all the things they had hoped for and more,” fellow Nobel Peace laureate Archbishop Desmond Tutu once said.
“He is by far the most admired and revered statesperson in the world and one of the greatest human beings to walk this earth.”
He was a global cause celebre during the long apartheid years, and popular pressure led world leaders to tighten sanctions imposed on South Africa’s racist white minority regime.
In 1988 at a concert in Wembley stadium in London, tens of thousands sang “Free Nelson Mandela” as millions more watched on their television sets across the world.
Born in July 1918 in the southeastern Transkei region, Mandela carved out a career as a lawyer in Johannesburg in parallel with his political activism.
He became commander-in-chief of Umkhonto we Sizwe (Spear of the Nation), the armed wing of the by now-banned ANC, in 1961, and the following year underwent military training in Algeria and Ethiopia.
While underground back home in South Africa, Mandela was captured by police in 1962 and sentenced to five years in prison.
He was then charged with sabotage and sentenced in 1964 to life in prison at the Rivonia trial, named after a Johannesburg suburb where a number of ANC leaders were arrested.
He used the court hearing to deliver a speech that was to become the manifesto of the anti-apartheid movement.
“During my lifetime, I have dedicated myself to this struggle of the African people. I have fought against white domination and I have fought against black domination. I have cherished the ideal of a democratic and free society.
“It is an ideal for which I am prepared to die.”
He was first sent to prison on Robben Island, where he spent 18 years before being transferred in 1982 to Pollsmoor prison in Cape Town and later to Victor Verster prison in nearby Paarl.
When he was finally released on February 11, 1990, walking out of prison with his fist raised alongside his then-wife Winnie.
Ex-prisoner 46664 was entrusted with the task of persuading the new president F.W. de Klerk to call time on the era of racist white minority rule.
Mandela and de Klerk were jointly awarded the Nobel Peace Prize in 1993 for their role in the ending of apartheid.
Derived from the Afrikaans word for “apartness,” apartheid was a brutally enforced system that discriminated politically and economically against “non-whites” and separated the races in schools, buses, housing and even public toilets and beaches.
After the ANC won the first multi-racial elections, Mandela went out of his way to assuage the fears of the white minority, declaring his intention to establish “a rainbow nation at peace with itself and the world.”
Critics said his five-year presidency was marred by corruption and rising levels of crime. But his successors, Thabo Mbeki and Jacob Zuma, have never enjoyed anywhere near the same levels of respect or affection.
In retirement, he focused his efforts on mediating conflicts, most notably in Burundi, as well as trying to raise awareness and abolish the taboos surrounding AIDS, which claimed the life of his son Makgatho.
His divorce from second wife Winnie was finalised in 1996.
He found new love in retirement with Graca Machel, the widow of the late Mozambican president Samora Machel, whom he married on his 80th birthday.
In one of his last foreign policy interventions, he issued a searing rebuke of George W. Bush on the eve of the US invasion of Iraq in 2003, calling him “a president who has no foresight, who cannot think properly, is now wanting to plunge the world into a holocaust”.
Bush’s predecessor Bill Clinton perhaps had a higher opinion of Mandela.
“Every time Nelson Mandela walks in a room we all feel a little bigger, we all want to stand up, we all want to cheer, because we’d like to be him on our best day,” he said.
Mandela is survived by three daughters, 18 grandchildren, nine great-grandchildren and three step-grandchildren. He had four step-children through his marriage to Machel.
His death has left his family divided over his wealth. Some of his children and grandchildren are locked in a legal feud with his close friends over alleged irregularities in his two companies.