The Duke of Edinburgh smiled and nodded to reporters as he left hospital in time to celebrate his 91st birthday on Sunday.
Philip shook hands with and thanked staff at King Edward VII Hospital in central London after spending five days there having treatment for a bladder infection.
The Duke got into the front passenger seat of a Land Rover Discovery vehicle before being driven away from the hospital, with a police escort.
When reporters shouted out questions about whether he was feeling better, the Duke nodded.
A Buckingham Palace spokesman said the Duke would be spending his birthday "privately".
On Friday, he enjoyed the company of grandsons the Duke of Cambridge and Prince Harry who paid a short, private visit.
William visited his grandfather while on leave from his RAF Search and Rescue duties. Harry, meanwhile, was spending the week since the Diamond Jubilee celebrations on pre-deployment training at Wattisham in Suffolk.
Philip had already been visited by the Queen, the Duke of York, the Earl and Countess of Wessex and their children, Louise and James.
Philip has been planning to celebrate his birthday privately and is not due to attend his next scheduled engagement until Tuesday, when the Queen hosts a garden party at the Sandringham Estate to mark her Diamond Jubilee.
The Duke's sense of humour has evidently not been damaged by his recent illness - asked outside the hospital if he was feeling better, Philip replied: "Well, I wouldn't be coming out if I wasn't."