Prince Philip, the 96-year-old husband of Queen Elizabeth II, left hospital on Thursday after two nights inside for treatment of an infection, Buckingham Palace said.
The royal patriarch, who is to retire from public duties later this year, was driven by car to a private London hospital on Tuesday as a precautionary measure concerning a pre-existing condition.
"I can confirm that the Duke of Edinburgh left hospital this morning," a spokesman told AFP. He was driven away from a rear exit.
Prince Philip was at Windsor Castle on Tuesday when he was taken to King Edward VII's Hospital. He was said to have been in good spirits inside.
He was expected to return to Windsor, where he is due to rest.
Prince Philip had been due to accompany the monarch to the state opening of parliament on Wednesday as well as day two of the Royal Ascot horse races.
Their eldest son Prince Charles, the heir to the throne, accompanied Queen Elizabeth to the Houses of Parliament in his place.
Prince Philip was with the monarch at the opening day of the Royal Ascot horse races near Windsor on Tuesday.
The prince has been the queen's dutiful husband for 70 years and announced his forthcoming retirement in May.
He is the longest-serving consort in British history, and is still in good health for a man of 96.
But the World War II naval officer, who conducted 219 royal engagements last year, has been gradually reducing his workload in his nineties.
Buckingham Palace would not go into details about Prince Philip's condition or the type of infection. However, his past history of a bladder infection could indicate his problem this week.
The former naval officer's irascible, no-nonsense approach, combined with his infamous and sometimes politically incorrect off-the-cuff remarks, has not made it easy for people to warm to his style.
But his forthright manner and unwavering devotion to duty and the queen has endeared him to the nation.
And observers say his quips put people at ease at events - while also providing a welcome contrast to the queen's seriousness.
In parliament on Tuesday, Prime Minister Theresa May said the whole House of Commons would join her in sending her best wishes to the prince.
"We wish him a full and speedy recovery," she said.
Britain's Prince Philip, 96, in hospital with infection
Prince Philip, the 96-year-old husband of Queen Elizabeth II, has been admitted to hospital as a "precautionary measure" for treatment of an infection, Buckingham Palace said Wednesday.
The infection arose from "a pre-existing condition", the palace said. The Duke of Edinburgh, who is to retire from public duties later this year, was admitted to King Edward VII Hospital in London on Tuesday night.
Prince Philip was due to accompany the monarch to the state opening of parliament on Wednesday as well as the Royal Ascot horse races.
Their eldest son Prince Charles, the heir to the throne, will accompany Queen Elizabeth to the Houses of Parliament in his place.
"Prince Philip is in good spirits and is disappointed to be missing the state opening of parliament and Royal Ascot," a Buckingham Palace spokesman said.
"Her Majesty is being kept informed and will attend Royal Ascot as planned."
Prince Philip was by Queen Elizabeth's side on Saturday for Trooping the Colour, her official birthday military parade in London.
In a change from tradition, he wore a dark suit rather than his red army uniform and heavy bearskin hat.