Saudi Arabia's King Salman bin Abdulaziz left hospital on Sunday following a colonoscopy last week, the royal court said in a statement on state media.
Saudi TV ran a video clip showing the monarch walking slowly using a cane as he left King Faisal Specialist Hospital in the city of Jeddah, where he was admitted on the evening of May 7.
An entourage kept close and his son, Crown Prince Mohammed bin Salman, the kingdom's de facto ruler, appeared in the clip.
Meanwhile, the Saudi Press Agency said on Twitter that King Salman underwent "medical examinations and successfully completed the treatment plan and recovery period."
The kingdom has for years sought to quell speculation over the health of the 86-year-old monarch. A week ago, state media reported that the king's colonoscopy results were "sound" and that doctors had "decided to keep him in the hospital for some time to rest".
In 2017, Saudi Arabia dismissed reports and mounting speculation that the king was planning to abdicate in favour of Crown Prince Mohammed, the de facto ruler.
King Salman, the custodian of Islam's two holiest sites, became ruler of the world's top oil exporter in 2015 after spending more than two and a half years as the crown prince and deputy premier.
He underwent bladder surgery in 2020 and had the battery of his heart pacemaker replaced in March.
Before this latest hospitalisation, he was most recently admitted in March for what state media described as "successful medical tests" and to change the battery of his pacemaker.
Under his rule, Saudi Arabia has launched ambitious economic reforms for a post-oil era and given more rights to women, while adopting a more assertive foreign policy, including entering a war in neighbouring Yemen.