The 94-year-old anti-apartheid icon will continue to receive medical care at home.
Mandela had been in the hospital since Dec. 8. In recent days, officials have said he was improving and in good spirits, but doctors have taken extraordinary care with his health because of his age.
Mandela was released Wednesday evening and will receive "home-based high care" at his residence in the Johannesburg neighborhood of Houghton until he fully recovers, said presidential spokesman Mac Maharaj.
"We thank the public and the media for the good wishes and for according Madiba and the family the necessary privacy," said Maharaj in a statement, using Mandela's clan name, a term of affection. The statement requested that Mandela's privacy continue to be respected "in order to allow for the best possible conditions for full recovery."
David Phetoe, a resident of the Johannesburg township of Soweto, reacted with joy when he heard that Mandela was no longer in a hospital.
"It's not always the case, when people offer great expectations, that those expectations are fulfilled," he said. "In this case, we say in the same tone, in the Christmas mood and in the Christmas season, let him stick around for a while!"
Mandela is revered around the world as a symbol of sacrifice and reconciliation, his legacy forged in the fight against apartheid, the system of white minority rule that imprisoned him for 27 years.
The Nobel laureate served one five-year term as president after South Africa's first democratic elections in 1994. Although the country today struggles with poverty and inequality, Mandela is widely credited with helping to avert race-driven chaos as South Africa emerged from apartheid.
South African President Jacob Zuma was among those who joined Mandela's wife, Graca Machel, and other family members in wishing a Merry Christmas to Mandela at his hospital bedside in Pretoria, the South African capital.
"I think he is an icon of hope and we are very excited" that Mandela is out of the hospital, said Sipho Sibiko, a Soweto resident. "I personally know that he is one of the people that inspired me. He inspires a lot of people and we are excited that he has been released. We wish him many more joyous years and good health."