The 96-year-old waved to well wishers as he left King Edward VII’s Hospital in London in a Range Rover.
Philip underwent the planned surgery on April 4 to install a prosthetic hip to alleviate pain.
“His Royal Highness The Duke of Edinburgh left King Edward VII’s Hospital at midday today, following a hip replacement operation last week," Buckingham Palace said in a statement. "The Duke will continue his recovery at Windsor.”
The statement continued, "His Royal Highness would like to convey his appreciation for the messages of good wishes he has received.”
Philip's daughter, Princess Anne, visited her father Thursday and said he was “on good form” after a 50-minute visit.
Queen Elizabeth, 91, speaking with well-wishers at an engagement in Windsor, said Philip was “getting on very well."
Philip had missed several events due to pain before electing to undergo the surgery.
He was absent from the royal family's Easter service attended by Queen Elizabeth and other royals, and also missed the annual Maundy Service with Queen Elizabeth at St. George's Chapel just a few days before Easter.
Philip also withdrew in March from a planned appearance with his son, Prince Andrew, the duke of York, at Windsor Castle to mark Andrew's role as colonel of the Grenadier Guards.
Andrew is taking over the role from Philip, who retired from royal duties last summer but still makes appearances with the royal family.