The statement from the office of President Jacob Zuma said there had been "a sustained and gradual improvement" in the condition of 94-year-old Mandela, who was admitted to a hospital on the night of March 27.
"The former President will now receive home-based high care," the statement said. Mandela had received similar treatment at his home in Johannesburg after a hospital stay in December.
During Mandela's hospitalization, doctors drained fluid from his lung area, making it easier for him to breathe.
It was his third trip to a hospital since December, when he was treated during a three-week stay for a lung infection and had a procedure to remove gallstones. Earlier in March, the anti-apartheid leader was hospitalized overnight for what authorities said was a successful scheduled medical test.
Mandela became South Africa's first black president in 1994 after elections were held, bringing an end to the system of white racist rule known as apartheid. After his release from prison in 1990, Mandela was widely credited with averting even greater bloodshed by helping the country in the transition to democratic rule.
The Nobel Peace Prize laureate has been particularly vulnerable to respiratory problems since contracting tuberculosis during his 27-year imprisonment for fighting white racist rule in his country.
The elderly are especially vulnerable to pneumonia, which can be fatal. Its symptoms include fever, chills, a cough, chest pain and shortness of breath. Many germs cause pneumonia.
South African officials have said doctors were acting with extreme caution because of Mandela's advanced age.
In Saturday's statement, Zuma thanked the medical team and hospital staff that looked after Mandela and expressed gratitude for South Africans and people around the world who had shown support for Mandela.