Michael Phelps won his 23rd Olympic gold in what looks like being his final Games, as Britain took silver in the men’s 4x100m medley relay.
Phelps, 31, secured his fifth gold of Rio 2016 when he teamed up with Ryan Murphy, Cody Miller and Nathan Adrian to set a new Games record of three minutes 27.95 seconds.
Britain finished 2.71 seconds adrift, with Australia in third.
USA also successfully defended their title in the women’s 4x100m medley.
Kathleen Baker, Lilly King, Dana Vollmer and Simone Manuel clocked 3:53.13 to win USA’s 1,000th gold at a summer Games.
“Getting off the bus and walking to the pool tonight, I pretty much felt myself starting to crack,” said Phelps.
“Last warm-up, last time putting on a suit, last time walking out in front of people, representing my country… it’s insane.
“This is how I wanted to finish my career. I’ve lived a dream come true. Being able to cap it off with these Games is just the perfect way to finish.”
The American legend bowed out with 28 medals from five Olympics after making his debut in 2000.
That is 10 more than the next best. Gymnast Larisa Latynina, who competed for the Soviet Union between 1956 and 1964, won 18, nine of them gold.
“This all started with one little dream as a kid to change the sport of swimming and try to do something nobody has ever done,” said Phelps.
“It turned out pretty cool. I’ve lived a dream come true. Being able to cap it off with these Games… it’s just he perfect way to finish.”
Britain’s James Guy, who took on Phelps in the butterfly leg of the relay, said he expects to see the American racing at the Toyko 2020 Olympics.
“I don’t think he’ll retire,” said Guy. “I think he wants 25 golds and he’s got 23.”
Murphy set the pace for the Americans in the first leg of the relay, recording a new backstroke world record of 51.85 seconds.
But a blistering breaststroke leg from 100m gold medallist and world record holder Adam Peaty, whose split was 56.59, put Britain into first place.
Phelps overtook Guy in the butterfly. Then Adrian held off Duncan Scott in the final leg to give the USA their 16th swimming gold medal in Rio.
Former British swimmer Karen Pickering on BBC One: “We’ve run out of words to describe what Michael Phelps has done.
“This comeback has coincided with such great form and we’ve seen much more of him emotionally. You get drawn into him.
“It seems such a shame if this is the last time we see him race.”
USA team-mate Cody Miller tweeted: “The G.O.A.T Michael Phelps isn’t just an incredible swimmer.. He’s an incredible person and team-mate.”
Phelps’s partner, Nicole Johnson, tweeted: “I’m at a loss of words… Just so incredibly proud of Michael Phelps and the amazing week he’s had!! What a way to close this chapter.”
The White House’s official Twitter account posted: “Hard work, focus, and a dream – that’s the spirit of Michael Phelps. Tonight, we congratulate him and all of Team USA on making history.”