Prince Philip has left hospital after a five-night stay receiving treatment for a bladder infection.
Smiling, he waved to well-wishers and shook hands with staff, a day before his 91st birthday on Sunday.
He was admitted to London's King Edward VII hospital on Monday, a day after attending the rain-drenched Jubilee river pageant with the Queen.
A spokesman for Buckingham Palace said: "The Duke of Edinburgh continues to make a good recovery."
He added: "He will continue his convalescence at home. He will spend the weekend privately."
The duke had appeared to be in good health when he accompanied the Queen on Sunday on the royal barge, the Spirit of Chartwell, which formed part of the river pageant.
His admission to hospital meant that he could not join the Queen at the final Diamond Jubilee events to mark her 60 years on the throne.
Princess Eugenie told Sky News the loss of her grandfather for the final two days of the Jubilee celebrations was keenly felt by the Queen.
"They are the most incredibly supportive couple to each other," she said.
"Grandpa was unfortunately taken ill and for granny to come and do that alone was probably quite testing and I think he is her rock, really, and she is his."
On Friday, the duke was visited by Princes William and Harry, the latest in a series of visits from his family.
Prince William visited the duke while on leave from his RAF search and rescue duties.
On Thursday, it was announced that he had qualified as a Royal Air Force search and rescue captain, after passing his tests on 29 May.
Meanwhile, his brother Prince Harry - a captain in the Army - has spent this week on pre-deployment training at RAF Wattisham in Suffolk.
The Queen and the Duke of York visited Prince Philip on Wednesday. Prince Andrew said his father was "mending very well".
He is not due to attend his next scheduled engagement until Tuesday, when the Queen hosts a garden party at the Sandringham Estate as part of Jubilee celebrations.