Earlier on Thursday he looked well as he attended a Buckingham Palace garden party and was also presented with the Order of New Zealand by Queen Elizabeth.

Guests at the garden party said he had been “telling jokes” and showed no signs of being unwell.

Sources said the Duke was not suffering from any pain or discomfort and had arranged to have the operation after doctors “picked something up” during a routine health check during the past week.

The Queen was said to be “naturally concerned” but both she and the Duke have taken the setback in their stride. The Queen carried on with her official duties Friday, opening the BBC’s new headquarters.

In a statement released Thursday night, Buckingham Palace said: “His Royal Highness The Duke of Edinburgh has been admitted to the London Clinic for an exploratory operation following abdominal investigations. He is expected to stay in hospital for up to two weeks. Further updates will be issued when appropriate.”

David Cameron was among the first to pass on his regards to the Duke, tweeting: “My best wishes to the Duke of Edinburgh who is in hospital tonight. I hope he has a swift recovery.”

It is understood that the Duke’s condition is unrelated to the bladder infection he suffered during last year’s Diamond Jubilee celebrations, which was thought to have been brought on by his prolonged exposure to the cold during the Thames River Pageant. It was also said to be unrelated to the blocked coronary artery he suffered in 2011, when he spent Christmas in Papworth Hospital near Cambridge after being airlifted from Sandringham, where he had complained of chest pain.

A source said: “He has been carrying out engagements all week and his hospital trip was planned in advance. He was driven there by car, walked into the hospital and will have the operation tomorrow.”

A two-week hospital stay would amount to the longest period the Duke has ever spent in hospital, but a Palace source said: “If anyone is going to have surgery at that age they are likely to be in hospital for that long.” The fact that the Queen is carrying on with her normal programme of engagements suggests the Royal family are sanguine about the Duke’s operation.

On Monday night the Duke pulled out of a dinner engagement but sources said he had merely lost his voice. The following day he appeared well when he accompanied the Queen to her coronation anniversary service at Westminster Abbey.

The 91-year-old was admitted to the London clinic — a private hospital and longtime favourite for the royals — after attending a garden party at Buckingham Palace. Philip appeared relaxed as he mingled with guests and told jokes at the party.

Officials have not released details about his condition but indicated he had had tests earlier in the week.

He had pulled out of one event this week but later attended a service at Westminster Abbey to mark the 60th anniversary of the coronation of his wife, Queen Elizabeth II.The queen continued with her working schedule Friday, officially opening the revamped and expanded BBC broadcasting facilities.

She seemed cheerful most of the time but at other times looked sombre and tired.