Philip, also known as the duke of Edinburgh, smiled warmly as he left Aberdeen Royal Infirmary and returned to the nearby Balmoral Castle, where the royal family has vacationed since 1852.
"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," senior staff nurse Denise Webster was quoted in the British newspaper The Daily Telegraph as saying.
His hospitalization, which began Wednesday, came 2 1/2 months after he spent five nights in hospital with a similar bladder infection during his wife's Diamond Jubilee celebrations marking her 60-year reign.
On Dec. 23, 2011, he underwent successful coronary angioplasty and stenting to clear a blocked artery after suffering chest pains while staying at the royal residence at Sandringham, England.
Buckingham Palace did not say if he will attend his next official engagement -- accompanying Elizabeth to the opening of the Summer Paralympic Games Aug. 29.
Philip is the commonwealth's longest-serving consort and the oldest spouse of a reigning British monarch.
'How to Train Your Dragon 2' releases 5-minute clip
Lytro unveils camera that can focus a photo after shooting it