The Duke of Edinburgh has been discharged from hospital after spending two nights being treated for an unspecified infection.

Philip was admitted as a precautionary measure on Tuesday night, on the advice of a doctor, after falling ill with an infection arising from a pre-existing condition.

The Duke left from the rear of the private King Edward VII’s Hospital in central London just before 10am on Thursday, and was driven away.

The Duke’s brief admission to hospital forced him to miss two major events in the Queen’s calendar on Wednesday, the State Opening of Parliament and Royal Ascot.

The Prince of Wales took Philip’s place at the Queen’s side when she went to Westminster to give a speech outlining the Government’s programme, and the monarch, who attended Ascot as usual, was kept informed about her consort.

With the Duke’s advancing years – he celebrated his 96th birthday on June 10 – there was likely to have been concern for his health.

The Queen and Duke of EdinburghThe Queen and the Duke of Edinburgh arrive for the Trooping the Colour (Jonathan Brady/PA)

But Buckingham Palace stressed on Wednesday that Philip was in “good spirits” during his time in hospital and a source said on Tuesday, when he was taken ill, he had been on “good form” when at Ascot with the Queen and members of his family.

The Duke has enjoyed good health throughout much of his life, recovering from a blocked coronary artery in 2011 and a bladder infection in 2012, the latter leading him to miss the majority of the Queen’s Diamond Jubilee celebrations and spend a period in hospital.

His decision to retire from public duties after the summer was not health-related, Buckingham Palace said at the time of the announcement earlier this year.

The Duke is an advocate of healthy eating combined with exercise and he once said he more or less followed the Atkins diet and he drinks only moderately.

He told a flu expert at a research centre last year that he had not had the illness for 40 years.