A fifth gold and teamwork with Phelps ensures America top the medal table over hosts China.
Lochte seals the issue for the US
A strong finish on the final day of the world swimming championships pushed the United States to the top of the gold medal table, as Ryan Lochte won the 400m Individual Medley for his fifth gold and Michael Phelps helped carry the 4x100 medley relay team to victory.
Lochte had a one-second lead after the opening butterfly leg and expanded it to two seconds over the backstroke and breaststroke legs before powering home in the freestyle to win by more than four seconds in 4mins 07.13secs.
"I'm glad this meet's over. It's been a long, long eight days," Lochte said. "Getting five gold medals is definitely great. The times I went, I know I can go faster."
Phelps finished with four golds after pushing the Americans in front during the butterfly leg in the medley relay. Nathan Adrian held off a comeback attempt by Australia's James Magnussen in the anchor leg.
In other events yesterday, Therese Alshammar, 33, of Sweden, won the women's 50m free and America's Elizabeth Beisel took gold in the women's 400m. Another American, Jessica Hardy, reclaimed the 50m breaststroke title she lost two years ago during a doping ban, and Liam Tancock gave Britain their second gold in as many nights in the 50m backstroke.
The Americans' performance on the final night moved them in front of China on the overall medals table - including diving and other sports - with 17 golds to China's 15.
Lochte leaves Shanghai having won all four of his individual events - and he beat Phelps in two of them. He took another gold, plus a bronze, with the US relay teams. Lochte also beat Phelps in two events at last year's US championships, then won six golds to Phelps's five at the Pan Pacific Championships in 2010 - prompting Phelps's coach, Bob Bowman, to acknowledge that Lochte was the best swimmer last year.
Now it is fair to say Lochte has had the edge over Phelps this year, too, setting up an enticing duel at next year's London Olympics.
Alshammar, a four-time Olympian, won the 50m free in 24.14secs ahead of two Dutch swimmers — Ranomi Kromowidjojo and Marleen Veldhuis. Britta Steffen, the defending champion and world record holder of Germany, withdrew earlier in the meeting.
Hardy missed the 2009 worlds while serving a one-year doping ban. She won in 30.19secs, while Yuliya Efimova, the 2009 winner of Russia, took the silver and another American, Rebecca Soni, got bronze.
Tancock's victory followed British teammate Rebecca Adlington's 800m free victory a day earlier, but his win will not create as much clamour going into next year's Games because the 50 backstroke is not an Olympic event.