(CNN) -- Record-breaking swimmer Michael Phelps was left stunned when his golden run at the U.S. national championships came to an abrupt halt, leaving his overall title tally stuck on 50.
The 14-time Olympic champion suffered a shock defeat to longtime rival Ryan Lochte in the 200-meter individual medley in Irvine, California on Friday.
It was Phelps' first defeat of the week, and his first in the discipline in 38 championship races.
The 25-year-old became the first U.S. swimmer to reach 50 national titles when he won the 100m butterfly on Thursday.
The day before he surpassed the 48 titles won by previous record-holder Tracy Caulkins, who retired in 1984, with victories in the 200m butterfly and freestyle.
"That hurt. I was saying to Ryan when we were sitting in the pool, I was like, 'Dude, I think about 20 meters left, I just saw you pass me like I was standing still.' I kind of ran into a brick wall," Phelps told the L.A. Times.
"I felt like my body shut down. My legs, and I felt like I couldn't turn over my arms. When I came off the wall, I tried to do an underwater kick and it really didn't work so well. I was just hoping the wall was going to come as fast as it could."
It was an impressive achievement by world record-holder Lochte, who had finished second in the 100m freestyle just 35 minutes before hitting the water again.
The 26-year-old came home in one minute 54.84 seconds for his first victory over Phelps (1:55.94 ) in their 18th top-level encounter. Phelps has twice won Olympic gold in the event but did not enter at the world championships last year when Lochte won.
"I wish I didn't do the 100 free before because I think I could have gone a lot faster in the 200 IM," Lochte said.
He completed a double after also winning the 400m medley on Tuesday, and finished second behind Phelps in the 200m freestyle.
Nathan Adrian's victory in the 100m free also gave him a double following his 50m victory on Thursday.
The swimmers will return to the same venue from August 18 for the Pan Pacific Championships, after which the U.S. team for next year's world championships in China will be named.