Mandela led South Africa's transition from white-minority rule in the 1990s, after 27 years in prison for his political activities.
He had been receiving intensive medical care at home for a lung infection after spending three months in hospital.
Announcing the news on South African national TV, President Jacob Zuma said Mr Mandela was at peace.
"Our nation has lost its greatest son," Zuma said.
"Although we knew that this day would come, nothing can diminish our sense of a profound and enduring loss."
South Africans have gathered outside the home of Nelson Mandela in Johannesburg, singing and chanting slogans to celebrate his life
Zuma said Mandela - who is known affectionately by his clan name, Madiba - had died shortly before 21:00 local time (19:00 GMT). He said he would receive a full state funeral, and flags would be flown at half-mast.
Crowds have gathered outside the house where Mandela died, some flying South African flags and wearing the shirts of the governing African National Congress, which Mandela once led.
The Nobel Peace Prize laureate was one of the world's most revered statesmen after preaching reconciliation despite being imprisoned for 27 years.
He had rarely been seen in public since officially retiring in 2004. He made his last public appearance in 2010, at the football World Cup in South Africa.
His fellow campaigner against apartheid, Archbishop Desmond Tutu, said he was "not only an amazing gift to humankind, he made South Africans and Africans feel good about being who we are. He made us walk tall. God be praised."
BA/BA