The greatest swimmer the world has seen, Phelps needed every ounce of energy and all of his big-race experience to defeat Lochte in a thrilling duel, the pair going stroke for stroke over all four laps.
There was never more than a tenth of a second between them at any stage but it was Phelps who got his hand to the wall first in a relatively slow time of one minute 45.70 seconds, to show that he is starting to get back to his best after struggling with form and motivation.
"It's been a while, so it felt better," Phelps said.
"It's okay, but there's still a lot that needs to be fixed."
Lochte, who has been beating Phelps regularly over the past year including the final of the 400m individual medley on Monday, was second by just 0.05 after making a tactical error.
"I know what I did wrong," Lochte said.
"I just waited too long, instead of going out faster. But I have another month to make sure I get that race down."
Phelps and Lochte also sealed their places in the 4x200m freestyle relay and have now qualified for three events in London, with plenty more to come.
Phelps could lock up another spot as soon as Thursday after booking his place in the 200m butterfly with the third fastest time in Wednesday's semi-finals.
Missy Franklin, the emerging star of American women's swimming, clinched her first Olympic berth when she won the 100m backstroke final in 58.85 seconds.
The 17-year-old from Colorado showed why she is looming as one of the big winners in London when she set the fastest time in the world this year.
Rachel Bootsma flashed home to finish second, edging out Natalie Coughlin, who won the event at each of the past two Olympics but won't defend her title in London.
"I've been dreaming about this all my life, I can't believe it's happened to me at 17," said Franklin, who also qualified fifth fastest for the 200m freestyle final. "It just shows that dreams do come true."
Matt Gevers, a silver medallist in Beijing four years ago, won the men's 100m backstroke final in 52.08, the second fastest time ever recorded.
Breeja Larson won the women's 100m breaststroke final in 1:05.92, upsetting world champion Rebecca Soni and world record holder Jessica Hardy.
Soni held on to take second and secure her place in the team for London while Hardy, who skipped the last Olympics after being slapped with a doping ban after taking a tainted nutritional supplement, missed out but still has a chance to qualify in freestyle.
Coughlin is also relying on the freestyle to get in the team while Katie Hoff bombed out of the 200 freestyle when she finished 20th overall, missing the semis.
Hoff made the Athens Olympics at age 15 and swam in six events at the 2008 Beijing Olympics but failed to win a gold medal in any of them and has been plagued by bad luck.
A day earlier, she finished 20th in the 400 freestyle and had pulled out of the 400 individual medley. She is still entered in the 800 freestyle but is suffering from a virus and is resigned to missing London.
"I felt better today, I was actually able to eat, but I just didn't have it," Hoff said. "But I don't want to make excuses."