President Jacob Zuma, in a televised announcement, said the Nobel laureate had died peacefully in his family's company at around 20:50 on Thursday.
He said flags around the country would be flown at half-mast from Friday until his funeral.
Tributes and condolences flowed in the early hours of Friday, and large crowds gathered outside Madiba's Houghton home.
Among those who paid tribute to Madiba were US president Barack Obama, his predecessors George HW Bush and Bill Clinton, Mandela's successor Thabo Mbeki, British Prime Minister David Cameron, Australian Prime Minister Tony Abbott, UN Secretary General Ban Ki-moon, Britain's Prince William, and various actors.
Obama: One of the most influential human beings
Tributes also streamed in from Mandela's colleagues, his freedom fighter comrades, and the public.
Many tributes shared the same sentiment - that Mandela had left a legacy that would inspire generations to come.
Obama said Mandela was "one of the most influential, courageous, and profoundly good human beings that any of us will share time with on this earth... I cannot fully imagine my own life without the example that Nelson Mandela set, and so long as I live I will do what I can to learn from him."
Mandela's two youngest daughters were at the royal premiere of Mandela: Long Walk to Freedom in London when their father died.
They left the cinema when they received the news.
The movie, which was released in South Africa last week, is based on Madiba's life.
Tutu: We are relieved his suffering is over
Anglican Archbishop Emeritus Desmond Tutu extended his thanks to the Mandela family for sharing Mandela with South Africa and the world.
"Although we collectively claim him as the father of our nation, and the pain we feel is similar to that of losing a close relative, he was your husband, your father and your grandfather," he said.
"We are relieved that his suffering is over, but our relief is drowned by our grief. May he rest in peace and rise in glory," he said.
Cameron said "a great light had gone out".
"Nelson Mandela was a towering figure in our time; a legend in life and now in death -- a true global hero.
"Meeting him was one of the great honours of my life. My heart goes out to his family, and to all in South Africa and around the world whose lives were changed through his courage."
Mourner: He is in a better place
At Madiba's house, cars lined up and mourners, some in pyjamas, took to the streets to celebrate the life of the former statesman.
Spirits remained high as groups sang struggle songs and the national anthem.
"This is a watershed moment for the nation. It is something that will forever unite us," said mourner Terry Bamela.
"I'm sad that he has passed, but I am glad that he is in a better place."