LONDON (Reuters) - Michael Phelps, his emotions overflowing as he swam his last competitive race before retiring, ended his record-breaking career on Saturday the only way he knew how, by winning another Olympic gold medal.
Joining forces with his American team mates, Phelps gave the sporting world one last view of his incredible talent and determination to win when the United States blitzed their opposition in the men's medley relay on the final day of the swimming competition at the London Games.
"I couldn't ask to finish on a better note," Phelps said. "I have done everything I wanted to do. I am very happy."
It was the perfect ending for the most decorated Olympian of all time who built a stockpile of medals that once seemed unimaginable.
He finished his career with 18 gold medals, six from Athens, eight from Beijing and four from London, twice as many as the next best in any sport.
Phelps also won two silver and two bronze medals during his career, giving him a total of 22, yet another record. Soviet gymnast Larisa Latynina held the previous record for almost half a century but Phelps set a standard that could last even longer.
When he finished his final race, the crowd at London's Aquatics Centre, including his mother Debbie, rose to their feet to give him a standing ovation.
Swimming's world governing body FINA presented him with their lifetime achievement award and Phelps' lifetime coach Bob Bowman whispered in his ear: "I love you."
"We hugged, he said 'We did it,' we smiled and I said 'yes we did' and that was it."
The U.S. have never been beaten in the men's medley relay at the Olympics so the outcome of Saturday's race seemed a formality when Phelps teamed up with backstroker Matt Grevers, breaststroker Brendan Hansen and freestyler Nathan Adrian.
The Americans were second at the halfway stage but the result became a foregone conclusion when Phelps dived in for the last time, rolling his powerful shoulders over and over for the last time to put his team back in front.
Japan finished second and Australia third but no-one could stop an American team on a mission to give Phelps the perfect send off.
"I felt pretty privileged to be in his last race," said Australia's Matt Targett, who went head-to-head with Phelps in the butterfly leg.
"I will tell my kids and grandkids I swam against one of the titans of the sport."
The U.S. also won the women's medley relay on Saturday to give Missy Franklin, who has emerged as the new face of the American team, her fourth gold medal in London.
Franklin teamed up with breaststroker Rebecca Soni, butterflyer Dana Vollmer and freestyler Allison Schmitt to smash the world record set by China three years ago.
Australia finished second and Japan third but neither team could keep up with the Americans after Franklin gave them the lead after the opening backstroke leg.
No-one may ever catch Phelps' record but Franklin, just 17 and still at high school, is already well on her way to becoming the greatest female Olympian of all time.
The record number of Olympic gold medals won by a woman is nine, held by Latynina.
"I don't think his shoes will ever be filled," said Franklin.
"I think his footsteps are just huge. But hopefully I can kind of make little paths right next to his."
Vollmer and Schmitt both won their third gold medals in London while Soni collected her second as the U.S. finished the eight day swimming competition with 16 golds, the same as the rest of the world combined.
China finished second with five golds after Sun Yang obliterated his own world record to win the 1500 freestyle final and become the first man in 32 years to complete the long-distance double.
Sun followed up his win in the 400 freestyle on the opening day of competition to win the grueling 30-lap race in a time of 14 minutes, 31.02 seconds, slashing more than three seconds off the previous world record of 14:34.14 he set at last year's world championships in Shanghai.
Canada's Ryan Cochrane took the silver medal while Tunisia's Oussama Mellouli, the Beijing Olympic champion, collected the bronze.
There was high drama before the start when Sun tumbled into the water after a spectator blew a whistle when the swimmers were crouched down and just about to go.
The starter had the discretionary power to disqualify him but gave Sun the benefit of the doubt and ordered a re-start as the public announcer asked the crowd to remain silent for the start.
When the race did get away, Sun regained his composure and went straight to the lead, churning through the water with seemingly effortless ease, and brought the crowd to their feet when he sprinted the last lap looking as fresh as when he began.
"I really cried at the finish line because I was afraid of a false start," Sun said.
"I was so scared that I would be disqualified. After so much pressure (I was glad) I could finish it."
Ranomi Kromowidjojo of the Netherlands completed the women's spring double by winning the 50 freestyle gold in 24.05, ahead of Aliaksandra Herasimenia of Belarus and her fellow Dutchwoman Marleen Veldhuis.
Editing by Greg Stutchbury