By Agence France-Presse
The Duke of Edinburgh, who turns 96 on June 10, is the longest-serving consort in British history, and is still in good health.
But the royal family's patriarch, who conducted 219 royal engagements last year, has been gradually reducing his workload in his nineties.
Prince Philip was in classic jovial form as he joined Queen Elizabeth at a service and lunch on Thursday for members of the prestigious Order of Merit.
When mathematician member Michael Atiyah said to him: "I'm sorry to hear you're standing down," the duke replied: "Well, I can't stand up much longer!"
On Wednesday he described himself as "the world's most experienced plaque-unveiler" on a visit to Lord's cricket ground in London.
"He's looking forward to enjoying more of his leisure time," a royal aide said.
"This is not a decision taken for medical reasons. The duke decided this is the right time; he's nearly 96 and most people will have retired 30 years earlier," the aide added.
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.
Prime Minister Theresa May offered him the whole country's "deepest gratitude and good wishes".
Queen's full support
Buckingham Palace said in their statement: "His Royal Highness The Duke of Edinburgh has decided that he will no longer carry out public engagements from the autumn of this year."
"In taking this decision, the duke has the full support of the queen."
He will attend previously scheduled engagements until August, and would not accept any new invitations thereafter.
However, "he may still choose to attend certain public events from time to time", the palace said.
Prince Philip has been ever-present at his wife's side since she took the throne in 1952.
They married in 1947 and will celebrate their 70th wedding anniversary on November 20.
Like her husband, Queen Elizabeth has gradually cut back her workload in recent years as they go into their nineties.
But she made a sacred vow before God and her people at her 1953 coronation to serve for life, which experts say she considers unbreakable.
"Her Majesty will continue to carry out a full programme of official engagements with the support of members of the royal family," the palace stressed.
It is likely that the monarch will be accompanied by younger members of the royal family on future engagements.
Prince William, second in line to the throne, has already announced that he is leaving his job as an air ambulance pilot this year in order to undertake more royal duties.
22,191 solo engagements
Prince Philip is patron, president or a member of more than 780 organisations, and while he will maintain his association with them, he will "no longer play an active role by attending engagements", it said.
He has conducted 22,191 solo engagements since 1952, the palace said.
His 219 engagements last year were made up of 101 official visits, 91 receptions and 21 other engagements.
They were all carried out in Britain as Queen Elizabeth and her husband have cut down their overseas travel.
They visited Germany and Malta in 2015 but have not left Europe since touring Australia in 2011.
May said Prince Philip's contribution to Britain, the Commonwealth and the wider world would be "of huge benefit to us all for years to come".
On behalf of the Canadian government, Prime Minister Justin Trudeau thanked him for his decades of service and wished him "all the best in his retirement".
Ouside Buckingham Palace, visitors said the prince deserved to put his feet up.
Pamela Strohmaier, from Vancouver in Canada, told AFP: "It's a surprise to me but I think he's due to retire. He's put in a long, lengthy service."
"I think he's at the age where he deserves to retire."
Archaeology student John Bilton, 22, said he remained "pretty popular", despite his "slightly iffy" remarks
Diane Cole, 76, a retired Briton living in Melbourne, Australia, said: "The thing I like the most is when he... speaks his mind."
Sarah Graham, 30, from Scotland, said: "It's about time because he is an old man, poor chap!"