London 2012: Michael Phelps, Ryan Lochte Tweet About Final Race

Ryan Lochte Michael Phelps Olympics Podium - P 2012
Getty Images

Ryan Lochte Michael Phelps Olympics Podium - P 2012

Phelps won a record-breaking 20th career medal on Thursday, narrowly beating his rival in the 200-meter individual medley.

Olympic swimmer Michael Phelps narrowly beat his rival Ryan Lochte on Thursday to take home his 20th career medal at the London Games.

Phelps won gold in the 200-meter men's individual medley race by only 63 hundredths of a second, with a time of 1:54.27. Lochte took the silver with a time of 1:54.90.

PHOTOS: Bob Costas and the Olympians: THR Snaps Team U.S.A.

Hungary's Laszlo Cseh won bronze with a time of 1:56.22.

In addition to having won the most career medals of any Olympian ever, Phelps on Thursday became the first man to win an individual event at three consecutive Games.

The matchup had been highly anticipated: Earlier, NBC removed the pay wall for its livestream of the event on its Olympics website.

A half-hour earlier, Lochte was upset in the 200-meter backstroke -- his best event -- taking home the bronze behind fellow American Tyler Clary.

PHOTOS: THR Talks to 4 Famous Olympians

Both Phelps and Lochte took to Twitter not long after the end of their final race.

"Had some ups and downs this Olympics but bringing 5 Olympic medals back to #USA now time to cheer for #USA #Jeah," Lochte wrote, using his signature phrase.

Of the earlier disappointment, he wrote: "Hell of a race with @TylerClary and @MichaelPhelps."

Phelps, meanwhile, had written earlier in the day about the two upcoming races.

"Last prelim swim complete... 2 big ones tonight... Nap time now... ," he wrote.

PHOTOS: Top 10 Olympic Uniforms

After his final race -- Phelps is retiring after the London Games -- he retweeted a message from fellow swimmer Missy Franklin, who also is competing at this year's Olympics: "Thanks missie [sic]!!! Congrats to you for tonight as well RT @FranklinMissy: Proud of my teammates @rebsoni @ryanlochte @MichaelPhelps @TylerClary @TyMcGill @Cullen_Jones @AnthonyErvin @swimhardy 4 an INCREDIBLE night."

For his part, Clary also chimed in after his win, writing: "This is unreal, I am an Olympic gold medalist!!! Thank you and I love you all!!!"

He also tweeted a photo of his medal with the message: "Ever see an Olympic gold medal up close??"