Surgeon General Vejaynand Ramlakan said Mr Mandela, 92, was suffering from ailments that were common in people his age but was in good spirits.
Deputy President Kgalema Motlanthe - using Mr Mandela's clan name - said: "Madiba is well."
South Africa's liberation hero flew from Cape Town to Johannesburg on Wednesday for a check-up.
Friends and family visited him amid tight security at Milpark hospital on Thursday.
On Friday Mr Ramlakan said Mr Mandela had suffered a respiratory infection, but was responding well to treatment and would be receiving home-based care.
"To us he is stable, but will be subject to intense monitoring," he told reporters.
"Medically, at present, there is no need to panic," he added.
After Mr Mandela's discharge, an ambulance surrounded by a police convoy drove him towards his home in the Johannesburg suburb of Houghton.
The BBC's Pumza Fihlani in Johannesburg says the news comes as a relief to many anxious South Africans.
"It's wonderful news. In a sense he is the one holding the country together," Johannesburg resident Brandon Quinn told the BBC.
Lerato Ledwaba, a 20-year-old university student, also expressed her joy: "As a young person in South Africa, Madiba means the world to me - he is my inspiration to strive for a better life for myself."
Mr Mandela's frailty has been underlined by his hospital stay, which is hard for some to accept, our reporter says.
"I am constantly surprised by his strength. He is old but we are not ready to lose him. I don't know if we'll ever have another leader like him," said another Johannesburg resident Karen van Rensburg, 50.
"Yes, he is a world icon but he is also a human being and he deserves his privacy. We should all just let him rest now," said Sizwe Mbatha, 28, a bank consultant.
During South Africa's apartheid regime Mr Mandela was jailed for 27 years. While imprisoned at Robben Island he had tuberculosis.
He became South Africa's first black president in 1994 and stepped down after one term in 1999.
Correspondents say he has seemed increasingly frail since retiring from public life in 2004.
His last public appearance was at the football World Cup closing ceremony last July.
South African former President Nelson Mandela has been discharged from a hospital where he spent two nights.