Michael Phelps made history in his final showdown with Ryan Lochte, becoming the first swimmer to win gold in the same event in three straight Olympics in the 200m individual medley on Thursday.

For Phelps, who plans to retire after his last Olympic race on Saturday, the triumph over Lochte proved he remained the top swimmer in the world, probably the best ever.

While Phelps is not the swimmer he was in 2008, when he won eight gold medals in Beijing, he has spent this year's games securing his place in Olympic record books. His 20 career medals -- 16 golds, two silvers and two bronzes -- make him the most decorated Olympian of all time. And now he owns the three-peat mark as well.

Phelps, amazingly, has a chance to complete another three-peat on Friday, in the 100m butterfly.

Check out our live blog for photos and continuing updates.

He will finish his Olympics – and his career – on Saturday, with the men’s 4x100m medley relay, so he could feasibly walk away with a 22nd medal.

After beating Lochte on Thursday, Phelps called his rival "one of the toughest competitors I've swam against."

Lochte, meanwhile, is still trying to escape Phelp's shadow. In a pre-taped interview broadcast on "Today" Thursday, Lochte, asked to describe the perfect race, described one in which he finally breaks away from Phelps:

“In the middle lane it's me and Michael. I look over at Phelps and we have a little stare-off, look who wants it more. We step on the blocks and take your marks, boom. I take off. I'm hitting the water like a rocket and I'm not looking back.”

Lochte, not one for modesty, said his imaginary clash ends with him dusting Phelps in the home stretch, breaking the world record in the process. “I get up on the lane lines and I unleash, my muscles are flexing and bulging, I'm like, yeah!”

Visit NBCNews.com for breaking news, world news, and news about the economy

Reality was not as glorious. But still, Lochte had a good day on Thursday.

Lochte took on Phelps less than 30 minutes after racing in the 200m backstroke, in which he came in third to teammate Tyler Clary, whose 1:53:41 finish was an Olympic record, and silver medal winner Ryosuke Irie of Japan. With that bronze, and the silver in the 200m IM, Lochte finished his work at the Londong games with two golds, two silvers and one bronze. That brought his career Olympic medal count to 11.

Phelps swam the 200m IM in 1:54:27, six tenths of a second ahead of Lochte. Laszio Cseh of Hungary finished third.

Also on Thursday, American Rebecca Soni broke a world record for the second time in two days, winning gold in the 200m breaststroke. Her unprecedented performance, which unfolded in 2:19:59, gave Soni a second gold in that event. She won it in Beijing in 2008.