South Africa's ailing former leader Nelson Mandela was discharged from hospital on Wednesday after spending almost three weeks being treated for a lung infection, the presidency said.

South Africa's ailing former leader Nelson Mandela was discharged from hospital on Wednesday after spending almost three weeks being treated for a lung infection, the presidency said.

"Former president Nelson Mandela was discharged from hospital this evening," said a statement from President Jacob Zuma's office.

"He will undergo home-based high care at his Houghton (Johannesburg) home until he fully recovers."

The much-loved 94-year-old anti-apartheid icon was admitted to a hospital in the capital Pretoria on December 8, after being flown from his rural home in Qunu, in the south of the country.

Doctors also discovered that he had developed gallstones and he had surgery to have them removed. "We request a continuation of the privacy consideration in order to allow for the best possible conditions for full recovery," the presidency statement said.