Former President Daniel arap Moi has been given a clean bill of health by doctors at Nairobi Hospital, where he was admitted last week.
Mr Moi, 94, was taken to the hospital on December 12 for a routine check-up.
In a statement on Monday, the former president's press secretary, Lee Njiru, said he had been discharged and was resting in his residence at Kabarnet Gardens, Nairobi.
“Mzee was released after his medical team, led by his physician Dr David Silverstein, gave him a clean bill of health following the check-ups. Mzee Moi has thanked Kenyans for their prayers," Mr Njiru said.
The press secretary said that on Sunday, President Uhuru Kenyatta drove to the hospital to wish Mr Moi a quick recovery.
Mr Moi has undergone check-ups at facilities including Ichilov Hospital in Tel Aviv, Israel.
While there in March, his knee was examined and he visited historical sites in Jerusalem.
The problem with his knee began on July 30, 2006 after he was involved in an accident in Limuru.
He had been travelling to Kabarak from Machakos, where he had presided over a graduation ceremony at Scotts Theological College.
On January 27, 2017 the former president underwent a minor surgery on his knee at the Aga Khan University Hospital in Nairobi.
Mzee Moi, who was the head of State from 1979 to 2002, has not engaged actively in politics but has met several leaders at his Kabarak home.
On April 12, Orange Democratic Movement leader Raila Odinga visited visited him, a move that sparked a debate about the 2022 general election.
On May 7, Deputy President William Ruto went to Kabarak but could not see Mr Moi, his handlers saying he was undergoing routine physical exercises with his doctors.
On August 25, Mombasa Governor Hassan Joho paid the ex-president a courtesy call at his home.
Others who have visited Mzee Moi are Central Organization of Trade Unions (COTU) Secretary-General Francis Atwoli, Devolution Cabinet Secretary Eugene Wamalwa, Mama Ngina Kenyatta, Wiper Democratic Movement leader Kalonzo Musyoka and State House Comptroller Kinuthia Mbugua.
Mr Moi's last public appearance was on October 26, 2017, when he cast his vote at the Kabarak University polling station during the repeat presidential election. He did not leave his car.
Mr Moi served as Kenya's second president following the death of Mzee Jomo Kenyatta on August 22, 1978.