The Duke of Edinburgh has left hospital, where he was receiving treatment for a pre-existing condition.

Prince Philip spent four nights at King Edward VII hospital in central London, and left at 8.49am on Tuesday. Police and royal protection officers stood guard around the hospital.

Philip, who turned 98 in June, got into the front passenger seat of a car in a secluded street behind the private hospital and did not respond to photographers as he was driven away.

He arrived at Sandringham later to spend Christmas with the Queen after the precautionary hospital admission on the advice of his doctor.

The Queen attending church on Sunday with (from left) Lady Louise Windsor, Viscount James Severn and Prince Edward, on the Sandringham estate. Photograph: Paul Marriott/Rex/Shutterstock

The royal family exchange gifts on Christmas Eve and have a formal dinner, after which Philip usually serves port or brandy to the men.

They attend the Christmas morning service at the Church of St Mary Magdalene on the royal estate and greet wellwishers, although Philip is thought unlikely to attend as he missed the service last year despite being in good health.

The duke, who retired from public duties in 2017, appeared to recover well from a planned hip replacement operation in April last year. Over the past decade he has also been admitted to hospital for abdominal surgery, bladder infections and a blocked coronary artery.

Philip escaped with minor injuries after a car crash in January which led him to give up his driving licence amid widespread criticism over his role in the incident.

Asked about his father’s health during a visit to flood-hit communities in South Yorkshire on Monday, Prince Charles told reporters: “He’s being looked after very well in hospital. At the moment that’s all we know … When you get to that age things don’t work so well.”

Buckingham Palace would not go into detail about the pre-existing condition, or the nature of the treatment.

The duke is known to be an advocate of healthy eating and regular exercise. He once said he largely followed the low-carbohydrate Atkins diet and he drinks alcohol in moderation.

He has given up riding carriages competitively, but earlier this year was photographed in the grounds of Windsor Castle holding the reins as he guided a horse and carriage through the estate.

In her annual Christmas message the Queen described 2019 as “quite bumpy”, in apparent reference to the UK’s impending exit from the European Union and her son Prince Andrew’s catastrophic interview about his friendship with the convicted child sex abuser Jeffrey Epstein.

She said the life of Jesus illustrated the importance of reconciliation and taught everyone “how small steps taken in faith and in hope can overcome long-held differences and deep-seated divisions to bring harmony and understanding”.

She added: “The path, of course, is not always smooth, and may at times this year have felt quite bumpy, but small steps can make a world of difference.”