Lochte, the Olympic 200 backstroke gold medalist, was almost level with Phelps at the 150-meter mark and kept pace through the last lap, before falling short in the lunge for the wall.
Phelps won in 1:45.61, with Lochte on 1:45.78. They were the fastest times in the world this year.
Phelps will contest three more events at the nationals, which are being used as selection trials for the Pan Pacific Championships being be held in the same University of California, Irvine pool later this month.
Olympic gold medalist Natalie Coughlin earned her place on the Pan-Pac team when she held off the fast-finishing Missy Franklin in the women's 100 backstroke, while David Plummer upset Olympic champion and world record holder Aaron Peirsol in the men's 100 backstroke, winning by three-hundredths of a second.
"I've been around for a really long time," said Plummer, who was on the 2006 Pan-Pac team and clocked 53.60 seconds on Wednesday.
"I've put in so much hard work. It's good that it paid off."
(Editing by Greg Stutchbury)