Media playback is unsupported on your device Media caption Prince Philip joked with a guest during an engagement, shortly after his retirement was announced
The Duke of Edinburgh is retiring from royal duties this autumn, Buckingham Palace has announced.
Prince Philip, who turns 96 in June, made the decision himself and the Queen supported him, a spokesman said.
"I'm sorry to hear you're standing down", one man told him at a royal lunch on Thursday. "Well, I can't stand up much," the duke quipped.
The duke will attend already scheduled engagements between now and August but will not accept new invitations.
The Queen "will continue to carry out a full programme of official engagements", the palace said.
The duke carried out 110 days of engagements in 2016, making him the fifth busiest member of the royal family, according to Court Circular listings.
He is patron, president or a member of more than 780 organisations and will continue to be associated with them, but "will no longer play an active role by attending engagements", Buckingham Palace said.
In the statement, the spokesman said the duke "may still choose to attend certain public events from time to time".
Hours after the announcement, Prince Philip was at his 26th public engagement of 2017: a service and lunch for members of the Order of Merit at St James's Palace.
At the reception, the duke quipped to mathematician Sir Michael Atiyah that he "can't stand up much".
By Peter Hunt, BBC royal correspondent
This is Prince Philip acting on his own advice, nearly six years later.
When he turned 90 he told the BBC it was "better to get out before you reach your sell-by date".
From the autumn, he will follow a path into retirement which is trod by many non-royals once they are in their sixties.
Today's announcement is a significant moment in the recent history of the British Royal Family.
A prince of Greece - with Danish, German and Russian blood - he has served the ancient institution, very publicly, for seven decades.
As an outsider - who was viewed with suspicion by the aristocracy - he struggled at first.
To his critics, he is a gaffe-prone prince.
His many supporters argue that this nonagenarian senior royal has played a crucial role sustaining the monarchy.
It's little wonder then that the Queen once called him her strength and stay.
BBC royal correspondent Nicholas Witchell said the duke - the longest-serving consort in British history - "clearly feels he now wishes to curtail" his "familiar role" in support of his wife.
He stressed there were "no health considerations" behind the move - other than the normal health precautions for a man in his mid-90s.
The duke attended Lord's Cricket Ground to open a new stand on Wednesday and was heard joking at the event that he is the "world's most experienced plaque unveiler".
He is famed for off-the-cuff remarks he has made at royal engagements over the years.
Media playback is unsupported on your device Media caption Prince Philip feeds Donna the elephant at the opening of the Centre for Elephant Care at Whipsnade Zoo
Prime Minister Theresa May said she offered the country's "deepest gratitude and good wishes" to the duke and praised his "steadfast support" for the Queen.
Labour leader Jeremy Corbyn wished the duke "all the best in his well-earned retirement", saying: "His Duke of Edinburgh's Award scheme has inspired young people for more than 60 years in over 140 nations."
Prince Philip set up the awards in 1956 and they have become one of the UK's best-known youth programmes, with young people carrying out challenges to earn bronze, silver or gold awards.
The Duke of Edinburgh 96 years old next month 70 years as Queen's companion 110 days of engagements in 2016
785 organisations have him as patron, president or member
4 million people have taken part in Duke of Edinburgh Awards PA
Liberal Democrat leader Tim Farron said it was a moment to "celebrate and take stock" of the duke's "enormous achievements".
Scotland's First Minister Nicola Sturgeon said the "steadfast support" the duke had given the Queen was "hugely admirable".
Image copyright AFP/Getty Image caption The Queen and Duke of Edinburgh celebrate their 70th wedding anniversary later this year
Buckingham Palace publishes details of official engagements up to eight weeks in advance. For the Duke of Edinburgh, these include:
Visiting Pangbourne College, Berkshire, for its centenary - 9 May
Presenting prizes at the Royal Windsor Horse Show - 14 May
Attending a dinner marking the 70th anniversary of the founding of Pakistan - 18 May
Visiting the Chelsea Flower Show - 22 May
Holding receptions for young people who have achieved a gold Duke of Edinburgh award - 24 May
Attending evensong to celebrate the centenary of the Companions of Honour - 13 June
Presenting the Prince Philip Award at ZSL London Zoo - 27 June
Hosting King Felipe of Spain during his state visit - from 12 July
US President Donald Trump is also due to make a state visit to the UK later this year, but no date has been announced for his trip.
The duke and the Queen celebrate their platinum wedding anniversary - their 70th - in November.
They have called a halt to long-haul travel in recent years, with younger royals carrying out those duties.
Royal commentator Dickie Arbiter said the duke is in "robust health", adding: "He is not giving up on life, just stepping [down] from full-time public engagements".
Taken part in 637 solo overseas visits
Image copyright Getty Images Image caption The Duke of Edinburgh and the Queen waved as they made their way to an engagement on Thursday
Former royal butler Grant Harrold said: "I love his wit and I think people will miss seeing that on a day-to-day basis. But I don't think it's him disappearing, I think it's just him being very sensible, he's 95 years old.
"He's slowing down and I'm sure we will still hear and see of him from time to time."
Have you ever worked with the Duke of Edinburgh? Share your views and experiences by emailing haveyoursay@bbc.co.uk.
Please include a contact number if you are willing to speak to a BBC journalist. You can also contact us in the following ways:
fernguts on May 4th, 2017 at 09:39 UTC »
I hope this means he's finally going on a stand-up comedy tour.
lovelynihilism on May 4th, 2017 at 09:35 UTC »
96 seems like a ripe old age to retire.
teamtomreviews15 on May 4th, 2017 at 09:22 UTC »
Lad is getting on a bit