SHANGHAI -- Michael Phelps knew it would take a world record to win the 200-meter individual medley at the world championships. He just thought it would come from him.
Instead, Phelps found himself on the losing end of a close finish Thursday, watching teammate Ryan Lochte celebrate the first world record set since high-tech bodysuits were banned 1½ years ago.
It was Phelps' second straight loss to his good friend, who had beaten the 14-time Olympic gold medalist in the 200 freestyle two nights earlier.
"They both sort of told me the same thing, I need to be in better shape," Phelps said. "If I want to be faster the work has to be there and it has to be there consistently."
Lochte sprinted to the wall in 1 minute, 54.00 seconds and then pumped his right arm before clasping hands with Phelps in the next lane. He lowered his old mark set two years ago in Rome by a tenth of a second.
"One word describes that race -- jeah!" Lochte said, using his favorite made-up expression.
Phelps checked his time of 1:54.16 and then slid over the lane rope in front of Lochte before making his way out of the pool. Hungary's Laszlo Cseh took the bronze in 1:57.69.
"We're usually on the other end of the close ones," said Bob Bowman, Phelps' coach.
The final was virtually a match race between Phelps and Lochte, with Phelps leading the opening butterfly leg by six-hundredths of a second. Lochte took over on the backstroke leg and held a narrow lead through the finish.
Phelps outsplit Lochte by 0.13 seconds on the closing freestyle leg.
"I thought I had it on the last stroke," said Phelps, who glided into the wall. "After thinking about it, I probably could have rushed another stroke in there and maybe gotten to the wall faster."
Before Lochte's 2009 world record, Phelps had set the previous eight world records in the event dating to June 2003.
"I knew a world record was going to win that race," Phelps said. "It says something that we're still able to do those times."
Lochte set two world records at short-course worlds in Dubai in December, the only other individual marks set during the last 19 months, a stretch in which he has been the dominant American swimmer.
"I wanted to do something that everyone thought was impossible," he said. "Since they banned those suits, everyone thought a world record would never get touched again. I just wanted to show everyone that can happen. That's why we have records -- they're meant to get broken."
As Lochte was building his credentials, Phelps was blowing off training for such leisure pursuits as golf. He got serious about next year's London Olympics only eight months ago.
"I didn't win because I wasn't as prepared as I should have been," he said.
Phelps had repeatedly ignored Bowman's warnings that time was running out on regaining the form that carried him to a record eight gold medals at the 2008 Beijing Olympics.
"This is something that will stick with him," Bowman said. "He's got the picture now."
Lochte and coach Gregg Troy deflected any notion that the torch has been passed from Phelps to the laid-back Floridian who once fueled his swimming with sugary Skittles and Sprite.
"I don't know if we're going to call a few hundredths of a second surpassing Michael Phelps," Troy said, "but it puts us in a good lead."
Lochte has three medals -- two gold -- and Phelps has four medals -- one gold -- through the first five days of the meet.
Two likely future stars emerged victorious Thursday, with Australia's James Magnussen winning the 100 freestyle and 16-year-old American Missy Franklin earning her third medal in as many events.
Magnussen overtook defending champion Cesar Cielo of Brazil on the final lap to win in 47.63 seconds.
"It means the world and I know it means a lot to Australian swimming as well," Magnussen said. "First person to win that event at a world championships from Australia, which is a pretty big deal. I think it puts men's sprinting in Australia back in the spotlight."
Brent Hayden of Canada earned silver in 47.95 and William Meynard of France took bronze at 48.00. Cielo finished fourth, and American Nathan Adrian was sixth.
Competing in his first world meet, the 20-year-old Magnussen created a buzz with his sizzling opening split of 47.49 against Phelps in the 4x100 relay last Sunday to help the Aussies win.
In the women's 50 backstroke, a non-Olympic event, Anastasia Zueva of Russia won in 27.79, with Aya Terakawa of Japan second at 27.93 and Frankin third at 28.01.
Franklin returned later to lead off the United States' winning 4x200 freestyle relay team. Her split of 1:55.06 would have won the 200 free the night before, when Italy's Fedrica Pellegrini took the gold in 1:55.58.
"I've never felt this strong," Franklin said. "I'm just having the time of my life."
Franklin, Dagny Knutson, Katie Hoff and Allison Schmitt won in 7:46.14 to reclaim the title the U.S. lost to China two years ago. Australia was second and the Chinese settled for bronze.
China's Jio Liuyang won the women's 200 fly at 2:05.55, giving the host country its fourth gold. Ellen Gandy of Britain was second and defending champion Liu Zige of China third.