The Duke of Edinburgh shared a joke with staff as he left Aberdeen Royal Infirmary today, telling them to "behave yourselves".
He was heading back to Balmoral Castle to enjoy the rest of his summer holiday after spending five nights in hospital receiving treatment for a bladder infection.
ITV News' Scotland correspondent Debbie Edward reports:
As he was leaving, the 91-year-old stopped to the shake the hands of staff who had treated him as if it were an official royal visit.
Prince Philip, who is famed for not wanting a fuss made about himself, was praised as a "very good patient" by senior staff nurse Denise Webster:
– Denise Webster, senior staff nurse
The Duke was a very good patient, and as he left the hospital he told staff to behave themselves and he said he was going back to enjoy the rest of his holiday.
A small group waved goodbye as his car left to take him back to Balmoral to join the Queen and other members of the royal family for his summer holiday.
Philip's latest health scare came at the end of a busy summer with both the Queen's Diamond Jubilee celebrations and UK Tour, and the Olympics, keeping the Duke busy.
He had travelled down to the Isle of Wight to spend the beginning of last week taking part in events during Cowes Week, in his role as Admiral and member of the Royal Yacht Squadron.
But after returning to Scotland he was taken last Wednesday by ambulance from Balmoral in the Cairngorms to the city hospital following a recurrence of a bladder infection.
In June, he was admitted to hospital with the same infection the day after braving cold, wet and windy conditions on the royal barge for several hours during the Diamond Jubilee Pageant on the River Thames.
During his time at Aberdeen Royal Infirmary, he was not visited by the Queen or other family members after being advised by doctors to rest, but he was in regular contact with relatives by telephone.