Prince Philip has left hospital after a five-night stay receiving treatment for a bladder infection.
He waved to well-wishers and shook hands with staff, before being driven to Windsor Castle, a day before his 91st birthday.
He was admitted to London's King Edward VII hospital on Monday, a day after attending the Jubilee river pageant.
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."
Asked outside the hospital if he was feeling better, the duke said dryly: "Well, I wouldn't be coming out if I wasn't."
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."
The Ministry of Defence said there would be two gun salutes in London at midday on Monday to mark the duke's birthday.
A 41-gun salute by the King's Troop will take place in Hyde Park, and a 62-gun salute by the Honourable Artillery Company will be fired at the Tower of London.
Prince Philip will not attend either of the events.
'Mending very well'
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".
The duke 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.