After undergoing a planned hip replacement last week, 96-year-old Prince Philip has left the hospital and will continue his recovery at Windsor Castle, Buckingham Palace said.
The Duke of Edinburgh left King Edward VII Hospital in London midday Friday, the palace said in a statement, adding that Philip offered his "appreciation for the messages of good wishes he has received."
Queen Elizabeth II's husband underwent a successful surgery on April 4, the palace said. He is expected to need a rehabilitation period and to use crutches for weeks.
The palace had previously said Philip was "comfortable and in good spirits" after the procedure.
Philip had suffered from hip pain in recent weeks. Before he went into the hospital on April 3, he missed a number of family events, including an Easter church service with the queen and other members of the royal family.
The British Orthopedic Association said Philip's surgery was necessary because he was suffering from osteoarthritis.
Ananda Nanu, the board's president, said hip replacement patients need strong pain relief after their operations. Most can be mobile 24 hours after surgery and increase their activity every day after that, he said.
"At the age of 96, there are slightly greater risks, but he will be looked after by an extremely skilled team," Nanu said of the prince.
The health scare comes at a busy time for the royal family. Prince William and his wife Kate are expecting their third child this month, and Prince Harry plans to marry American actress Meghan Markle on May 19 at Windsor Castle.
Philip was an avid sportsman for many years and saw active duty in the Royal Navy during World War II. He has supported many charities, including the Duke of Edinburgh's Award, which he founded in 1956. The charity has been active in more than 100 countries and has helped thousands of young people.
Philip announced his retirement from royal duties in May and curtailed most of his charity work although he still accompanies the queen on occasion. He has carried out some 22,000 solo royal engagements since Elizabeth became queen in 1952.
They recently celebrated their 70th wedding anniversary. Elizabeth, usually so guarded with her personal emotions, has publicly called him the rock that she depends on.
Philip has suffered from heart disease and other ailments in recent years.