This goodbye was golden.
Michael Phelps put the United States ahead to stay on the butterfly leg of the 4x100 medley relay, his last race before retiring, and Nathan Adrian finished it off, giving Phelps, the most decorated athlete in Olympic history, his 23rd career gold medal.
Two-time gold medalist Ryan Murphy put the Americans out front with a world-record split on the backstroke but Britain surged ahead on the breaststroke and Phelps dived into the pool in second place.
On the return lap, Phelps powered through the water with his whirling butterfly stroke, surging ahead of James Guy to pass off a lead to the anchor Adrian.
If this was indeed the end, then Phelps went out in style, with 28 medals overall, having won five golds and a silver in Rio de Janeiro.
The victory came just minutes after the women's medley relay gave the United States its 1,000th Olympic gold medal in the history of the Summer Games.
Also on Day 8 of the Games, Usain Bolt thrilled the crowd at Olympic Stadium in his first appearance in Rio competition and Rafael Nadal's bid for an unprecedented second Olympic singles gold medal ended with a thrill-a-minute semifinal loss to Juan Martin del Potro.
Monica Puig won Puerto Rico's first gold medal in any sport in Olympic history, upsetting Angelique Kerber in the women's tennis singles final. Puig is ranked 34th and is the first unseeded women's singles gold medalist since tennis returned to the Olympics in 1988.
Seeded second, Kerber won the Australian Open in January and was the runner-up at Wimbledon last month. She was trying to give Germany its first singles gold since Steffi Graf in 1988, but instead goes home with silver.
While competitions wrapped up in swimming and rowing, they're just heating up in track and field, where Mo Farah of Britain recovered from a fall to defend his Olympic 10,000-meter title and American Jeff Henderson overtook Luvo Manyonga of South Africa on his last jump to win the long jump gold medal.
Elaine Thompson won the women's 100-meter title in 10.71 seconds, ending fellow Jamaican Shelly-Ann Fraser-Pryce's bid to win the event for a third straight Olympics. American Tori Bowie took silver.
Phelps also said the London Games were his last four years ago only to change his mind.
He insists he won't be coming out of retirement again for Tokyo in 2020.
"I'm not going four more years and I'm standing by that," he said. "I've been able to do everything I've ever put my mind to in the sport and after 24 years in the sport, I'm happy with how things finished."
Other highlights from Day 8:
GOLF GOLD: For all the talk about top players skipping Rio, the sport couldn't have asked for a better final round. Justin Rose of Britain is the third-round leader and will be trying to win golf's first gold medal in 112 years. Rose made two eagles in the opening five holes and shot a 6-under 65 to build a one-shot lead over British Open champion Henrik Stenson.
SLUGGISH SPRINTER: Bolt did not disappoint the crowd, but he was displeased with himself. He was slow out of the blocks but once his tall majestic frame reached full flow, there was no stopping him. "It wasn't the best start, it felt kind of sluggish," Bolt said, adding that he never has been a morning person and preparations for his noon race felt unusual.
LONELY RUSSIAN: The IAAF has banned the only Russian in Olympic track and field from competition and she is appealing the ruling. A decision on Darya Klishina's petition is expected before the long jump competition begins Tuesday. The former European indoor champion was the only one of 68 Russians allowed to compete in track amid a doping scandal.
GOODBYE GREEN: After blaming algae, heat and even the number of swimmers for the green water at Maria Lenk Aquatics Center, officials now say a contractor mistakenly dumped hydrogen peroxide into the pool, causing an adverse reaction with chlorine. So, they're draining the larger pool to transfer nearly 1 million gallons from a nearby practice pool.
PHOTO FINISH: After rowing for more than a mile, the gold medal came down to an inch. New Zealand's Mahe Drysdale and Croatia's Damir Martin crossed the finish line in the men's single sculls side by side, not knowing which one of them was the new Olympic champion. A photo analysis showed Drysdale won by a thumb's length.