Philip, whose official title is the Duke of Edinburgh, had been receiving treatment at the King Edward VII Hospital since Friday.
He walked out of the hospital on Tuesday morning, dressed ina dark suit, and shook hands with a nurse before getting into the front passenger seat of a car and being driven away.
The prince then travelled by helicopter to Sandringhame state in eastern England where the royal family traditionally gathers for Christmas.
“The Duke of Edinburgh has today left hospital after being discharged by his doctor and is now back at Sandringham. His Royal Highness would like to thank everyone who sent their good wishes,” Buckingham Palace said in a statement.
Philip had been taken to hospital as a precautionary measure for treatment for a pre-existing condition, the palace said on Friday.
The 93-year-old queen travelled to Sandringham on Friday.
It was not clear if Philip will accompany her to a Christmas Day church service on Wednesday, which he missed last year.
Philip retired from public life in August 2017, although he has occasionally appeared at official engagements since.
He spent Christmas of 2011 in hospital after an operation to clear a blocked artery and he missed the end of celebrations to mark his wife’s 60th year on the throne in 2012 after being hospitalised with a bladder infection.
In 2013, the Greek-born former naval officer underwent “an exploratory operation following abdominal investigations.”
He was admitted to hospital in 2017 for treatment for an infection, also arising from a pre-existing condition, and last year spent 10 days in hospital for hip-replacement surgery.
In January 2019, the prince was unhurt when his Land Rover flipped over after a collision with another car near Sandringham. He gave up his driving licence after police gave him a warning for driving without wearing a seat belt.