The 92-year-old Duke of Edinburgh waved and smiled to bystanders before being driven off from the London Clinic on Harley Street, where he had an exploratory operation under general anaesthetic on June 7.
He appeared relaxed as he said goodbye to medical staff at the hospital and walked unaided to a waiting vehicle to be driven to Windsor Castle, a royal residence in the English county of Berkshire.
The Prince thanked the medical team and members of the public who had sent him good wishes.
Throughout his stay, family members visited him, including the Queen, his sons Charles and Edward, and grandsons William and Harry. Prince Charles visited his father on Friday and said his condition was "much better".
Also Read
He was unable to attend the "Trooping the Color" ceremony on Saturday celebrating the 87-year-old Queen's birthday.
An operation, which had been pre-arranged after abdominal investigations, was carried out the next day. Details about what prompted the surgical procedure have not been made public.
Prince Philip received more than a thousand cards from well-wishers during his time at the London Clinic.
In recent days he has reportedly been asking for paperwork from his office and is expected to resume his official duties in the autumn.
The Duke, who turned 92 on June 10, will initially spend time at Windsor Castle, where the Queen is staying during Royal Ascot week.