The Duke of Edinburgh has left hospital, 11 nights after he was admitted for exploratory abdominal surgery.
Prince Philip, 92, walked out of the private London Clinic where he had been recovering since his admission on 6 June.
Buckingham Palace has previously said the surgery was pre-arranged and not an emergency.
He is expected to take about two months to convalesce, the palace said.
He had been expected to stay for two weeks, and missed several official royal events during his stay, but is due to resume his official duties in the autumn.
As he left the clinic he shook hands with staff, then waved and smiled to waiting journalists before getting into a car to be driven to Windsor Castle.
"The duke is in good condition and good spirits. He'll take a period of convalescence, of approximately two months," Buckingham Palace said in a statement on Monday morning.
"The duke has expressed his thanks and appreciation to medical staff at the London Clinic and the many members of the public who have sent good wishes."
Philip received more than 1,000 cards from well-wishers while at the hospital.
Throughout his stay family members visited him, including the Queen, his sons Charles and Edward, and grandsons William and Harry.
Details about what prompted the surgical procedure have not been made public.