JOHANNESBURG — Former South African President Nelson Mandela was released from the hospital Saturday after being treated for pneumonia, the government said.

Mandela, 94, has been hospitalized three times in the past four months. He has suffered from repeated lung infections, a legacy of the tuberculosis he contracted during his 27 years as a political prisoner of the white-minority government in South Africa.

Mandela was robust during his decades as a public figure, but in recent years, he has become frail. He last made a public appearance at the 2010 World Cup soccer tournament, where he didn’t deliver an address and was bundled up against the cold in a stadium full of fans.

South Africans hold the former leader dear as a symbol of sacrifice and reconciliation stemming from his pivotal role in steering South Africa from the apartheid era and into democratic elections in 1994, at a time of great hope but also tension and uncertainty.

Unlimited Digital Access. $1 for 4 weeks.

The new South Africa, beset by economic inequality, crime and corruption, has not lived up to the soaring expectations of its people, but they still see hope through their icon, Mandela.

He was admitted to the hospital, which was not identified, on March 27.

He was transferred in a military ambulance Saturday afternoon to his Johannesburg home, where his medical treatment will be continued.