The royal residence said Prince Philip had the "successful hip replacement operation" at King Edward VII's Hospital in central London, which often treats members of Britain's royal family.
Philip had suffered from hip pain in recent weeks.
BBC royal correspondent Jonny Dymond said the duke was an "intensely private man" and even at the best of times, the palace would not provide a running commentary.
While Prince Philip has been in a fairly healthy condition throughout his life, he had been reportedly treated for a blocked coronary artery in 2011, and a bladder infection in 2012.
Philip 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, which he is taking over from Philip. A few days before, The Queen's husband also missed the Maundy Thursday service at St George's Chapel.
In January 1998, the Queen Mother underwent hip replacement surgery at the age of 97.
The queen missed a traditional Christmas church service in late 2016 for the first time in decades due to a heavy cold and was hospitalized in March 2013 with symptoms of gastroenteritis.
The Duke of Edinburgh retired from royal duties last summer but still makes appearances with the royal family.
It is understood that the operation will require a general anaesthetic.
In his customary good humor, Philip joked to a well-wisher who said he was sorry the duke of Edinburgh was standing down shortly after the retirement announcement by responding, "Standing down?"
When it was announced past year that he would be retiring from official engagements, Buckingham Palace stressed that the decision was not health-related and he had the full support of the Queen.
Philip has had a number of hospitalizations in the last 10 years.
Wednesday's elective surgery was planned as the Duke has been suffering from pain with his hip for the last month or so.
Also invited will be 200 people from various charities associated with the couple, 100 students from two local schools, 610 Windsor Castle community members and 530 Members of The Royal Households and Crown Estate.