Michael Phelps said goodbye with an 18th Olympic gold medal Saturday, the US men remaining unbeaten in the 4x100m medley relay on a last record-setting night of swimming at the London Aquatics Centre.
In what he has vowed was his final race, the four-time Olympian took his career medals tally to 22 -- including the epic eight gold he won in Beijing four years ago.
China's Sun Yang offered a worthy curtain-raiser to Phelps' finale as he shrugged off a heart-in-mouth moment at the start to destroy the field and win the 1,500m freestyle gold in a world record time, while America's 4x100m medley women also won in a world record.
As so often, however, Phelps was the focus.
Breaststroke star Kosuke Kitajima had given Japan a narrow lead when Phelps dived in for the butterfly leg of the men's relay.
Takeshi Matsuda maintained the lead at the 50m mark of the fly, but Phelps delivered a classic final lap to seize the lead for the Americans and 100m free gold medallist Nathan Adrian was untouchable in sealing the victory in 3:29.35.
Sun shook off a heart-in-mouth moment at the start, when he slipped and hit the water as the other swimmers stood up before the start.
He wasn't charged with a false start that would have ended his night, and after the public address announcer instructed the crowd to maintain silence, a seemingly shaken Sun joined the rest of the field in returning to the blocks and powered to a win in 14:31.02, bettering the previous world record he set last year at the world championships in Shanghai.
"I thought I was going to be disqualified," admitted Sun, who said he couldn't hear the starter properly over the crowd noise. "I didn't expect the false start and I was very worried about being disqualified."
Once away, Sun was never challenged as he became the seventh man, and the first since Russian distance freestyle great Vladimir Salnikov in 1980, to win both the 400m free and 1500m free at the same Olympics.
Sun's triumph in the 400m free last Saturday made him the first male swimmer from China to claim Olympic gold and he earned silver in the 200m free.
Sun beat the water in joy, then covered his face as he broke down in tears before exiting the pool as he followed up on the world title he won by breaking Australian Grant Hackett's 10-year-old world mark in the event last year.
More than eight seconds back, Canadian Ryan Cochrane took silver in 14:39.63 and Beijing champion Oussama Mellouli earned bronze in 14:40.31.
The US quartet of Missy Franklin, Rebecca Soni, Dana Vollmer and Allison Schmitt won the women's 4x100m medley relay in a world record of 3:52.05.
Franklin, 17, claimed her fourth gold of the Games as part of the formidable line-up. She, Vollmer and Soni had all set individual world records here.
Australia took silver in 3:54.02 and Japan claimed the bronze in 3:55.73.
Dutch speedster Ranomi Kromowidjojo posted an Olympic record of 24.05sec to win the women's 50m free, completing a 50m-100m freestyle double ahead of Aliaksandra Herasimenia of Belarus (24.28) and Dutch team-mate Marleen Veldhuis (24.39).