The Duke of Edinburgh is giving up his public duties from the autumn, Buckingham Palace has announced.
The palace said Prince Philip, who turns 96 next month, had taken the decision with the "full support" of the Queen.
The Duke, who has had some medical problems over the years, appeared to be in good health on Wednesday and well enough to go about his usual business.
He opened the new £25m Warner Stand at Lord's cricket ground, named after former England captain Pelham Warner - one of 22,191 solo official engagements he has carried out.
As he pulled a cord to reveal a monument to his visit, he joked: "You're about to see the world's most experienced plaque-unveiler."
Over the years he has made 637 solo overseas trips as well, given 5,493 speeches and authored 14 books.
He still has a busy calendar of 24 engagements to fulfil before he steps down, including the Regimental Remembrance Service at Wellington Barracks in London later this month, and hosting the King and Queen of Spain next month.
But it appears he believes the time has come to take a step back from royal duties that can often involve extensive travel.
However, a royal aide stressed he would continue to attend royal events and not completely disappear from public life, adding: "He's looking forward to enjoying more of his leisure time."
Buckingham Palace said in a statement: "Prince Philip will attend previously scheduled engagements between now and August, both individually and accompanying The Queen.
"Thereafter, the Duke will not be accepting new invitations for visits and engagements, although he may still choose to attend certain public events from time to time.
"The Duke of Edinburgh is patron, president or a member of over 780 organisations, with which he will continue to be associated, although he will no longer play an active role by attending engagements.
"Her Majesty will continue to carry out a full programme of official engagements with the support of members of the Royal Family."
Thursday's announcement followed an emergency meeting of the royal household at Buckingham Palace, ahead of which officials asserted there was "no cause for alarm".
It is believed staff from royal residences across the country - including Windsor Castle and Sandringham - were asked to attend the London summit on Thursday morning.
The aides were addressed by the Lord Chamberlain, the most senior aide of the royal household, and the Queen's right-hand man, private secretary Sir Christopher Geidt, and later could be seen leaving the premises through the palace gates.
Shortly afterwards, the Queen and Prince Philip left Buckingham Palace for a service for members of the Order of Merit at St James' Palace, before hosting a lunch for those attending.
During the event, an attendee told him he was sorry to hear that he was standing down, to which the Duke replied: "I can't stand up much!"
The first sign the Duke was considering taking a step back from public duties came in 2010 when he announced he would be relinquishing his association with several of his charities on his 90th birthday.
Sky's Royal Correspondent Rhiannon Mills said: "The children and grandchildren have often described him as a very good sounding board.
"Within the inner family sanctum they talk about how he's been a real support over the years.
"It'll be interesting to see how much he decides he should be there by his wife's side, after all, he's been there seven decades - it's their 70th wedding anniversary in November.
"Yesterday when he was attending Lord's... he still looked remarkably sprightly. He still seems to be very fit and active."
Prime Minister Theresa May offered her "deepest gratitude and good wishes" to the Duke.
She added: "From his steadfast support for Her Majesty the Queen to his inspirational Duke of Edinburgh Awards and his patronage of hundreds of charities and good causes, his contribution to our United Kingdom, the Commonwealth and the wider world will be of huge benefit to us all for years to come."
Labour leader Jeremy Corbyn also paid tribute to the Duke "for his service to the country" and wished him all the best in his "well-earned retirement".
Liberal Democrat leader Tim Farron said the Duke was retiring "30 years later than most people" and described it as "a moment to celebrate and take stock of the enormous achievements that he has made in his life so far".
The Duke of Edinburgh Award said in a statement: "We would like to thank his HRH for his direction and support in creating the world's leading youth achievement award."
The scheme hailed his "tireless" work "to enable millions of young people to have the opportunity to transform their lives".
International trade minister Greg Hands recalled the first time he met Prince Philip. He tweeted: "I bowed clumsily, and he asked "Are you new?" #PrincePhilip."
Journalist Eve Pollard said the last time she saw him was at a press reception where she was drinking white wine.
"I remember him advising me that he now sticks to beer, at his age, he says it makes him feel much better and it's good for you," she told Sky's All Out Politics show.
Ingrid Seward, editor of Majesty Magazine, said she was not surprised "because I think the Queen has been anxious that Prince Philip does too much".
She told Sky News: "What people don't realise is that the Queen even now is very, very shy and she also finds it a great big effort to go amongst people she's never met before... and Prince Philip started doing those gaffes as a way of breaking the ice."
Sky's Royal Commentator Alastair Bruce added: "What's incredible is, he still goes out carriage driving, he's still very active. In the end I think you just probably want to enjoy a little bit of time to yourself."
Prince Philip's decision to retire comes after a momentous six-year period for the Royal Family.
This has included the Duke and Duchess of Cambridge's wedding in 2011, the Queen's 90th birthday last year and her passing her great-great-grandmother Queen Victoria's record in September 2015 to become Britain's longest-reigning monarch.
It means the Queen will now have more solo engagements, as will other royals, such as Prince William, who will be leaving his job as an air ambulance helicopter pilot in the summer to take on more royal duties.
Despite turning 91 last month, the Queen carried out royal engagements on 24 days in the first 72 days of the year, also working every day on official papers contained in her red boxes.
In 2016 she matched Prince William, with 80 days of official engagements.