Media playback is unsupported on your device Media caption Prince Philip was seen leaving the King Edward VII's Hospital in London on Tuesday morning

The Duke of Edinburgh has returned to Sandringham in time for Christmas after four nights in hospital.

Prince Philip, 98, was taken to the King Edward VII's Hospital in London on Friday on the advice of his doctor.

Buckingham Palace said the duke had returned to the Queen's Sandringham Estate in Norfolk on Tuesday and thanked people for "their good wishes".

It comes after the revelation the Queen will use her Christmas Day message to acknowledge 2019 has been "bumpy".

The monarch herself travelled to Sandringham on Friday.

The palace, meanwhile, said the duke's hospital admission had been a "precautionary measure".

Prince Philip retired from public life in August 2017 after decades supporting the Queen and attending events for his own charities and organisations.

His last public appearance was Lady Gabriella Windsor's wedding in May.

Image copyright REUTERS/Hannah McKay Image caption Buckingham Palace said the admission was a "precautionary measure" in relation to a "pre-existing" condition

The Prince of Wales said on Monday his father had been "looked after very well" by hospital staff.

But Charles, who was visiting flood-hit communities in South Yorkshire, added: "When you get to that age things don't work so well."

Royal commentator Caroline Aston told the BBC it was "entirely in keeping with the man" for Prince Philip to have seemingly had no visitors during his hospital stay, because he likes to make "no fuss about anything".

The Queen, 93, recorded her annual Christmas Day message before Prince Philip was admitted to hospital.

In the message, to be broadcast on BBC One at 15:00 GMT on Christmas Day, the monarch will say the path is never "smooth" but "small steps" can heal divisions.

Image copyright Steve Parsons/PA Media Image caption Queen Elizabeth II recorded her annual Christmas message from Windsor Castle in Berkshire

After a year of intense political debate over Brexit, as well as a number of personal events affecting the Royal Family, the Queen will say: "Small steps taken in faith and in hope can overcome long-held differences and deep-seated divisions to bring harmony and understanding."

In January, the Duke of Edinburgh was involved in a car crash while driving near Sandringham. He escaped uninjured, but two women required hospital treatment.

In September, the Duke and Duchess of Sussex publicly revealed their struggles under the media spotlight during their tour of southern Africa.

And last month, the Duke of York withdrew from public life after a BBC interview about his ties to sex offender Jeffrey Epstein, who killed himself in August.

Speculation

As is customary, family photos can be seen positioned near the Queen for her annual speech.

Addressing speculation about the absence of a photo of the Sussexes, the BBC's royal correspondent Nicholas Witchell said it was not in the Queen's nature "to snub anybody", adding: "Certainly not her grandchildren."

He said that the photos on the Queen's desk focus on the line of succession.

There has also been speculation surrounding which members of the royal family will attend the church service tomorrow morning.

BBC news correspondent Charlotte Gallagher said it was believed Prince Andrew would be at the service, as well as Prince George and Princess Charlotte.

Analysis: A coded message?

It has been a year which, at times, may have felt "quite bumpy", so the Queen will say in her Christmas broadcast.

It is a choice of words which will inevitably prompt speculation about what it is that she's referring to.

She does not offer any clarification herself, though the remark is made in the context of overcoming what she calls "long-held differences" and how "small steps taken in faith and in hope can overcome deep-seated divisions".

The obvious interpretation is that this is the Queen's - as ever - coded message to the country to try to move on from the divisions of the Brexit debate, but the reference to a "bumpy" year may also be taken to refer to events within her own family after a year which has seen the Duke of Edinburgh's car accident, the Duke and Duchess of Sussex complaining about the difficulties of being in the public eye and the controversies around Prince Andrew.

Last Christmas, Prince Philip missed the royals' traditional Christmas Day trip to church but was said to be in good health.

In February, it was announced the duke had given up his driving licence. It came after he was involved in a collision with another vehicle near the Sandringham Estate.

The treatment he has received for various health conditions over the years include being treated for a blocked coronary artery in 2011.

The following year, the prince suffered a bladder infection and was forced to miss the Queen's Diamond Jubilee concert.

He was also taken to hospital for an abdomen operation in 2013 and, in 2014, underwent surgery on his right hand.

Last year he had a hip replacement at the same central London hospital that he is now attending.