Michael Phelps Rio Olympics
Michael Phelps with his US teammates after winning his 23rd and final gold medalReuters

Another race, another gold and Michael Phelps bid goodbye to the pool in the best possible manner, like he knows only how. The most successful Olympian in history ended his incomparable career by winning gold for the USA in the 4x100m medley relay.

That medal was Phelps' 28th overall, 23 of which have been gold, obviously a record. Having beaten a mark of over 2000 years ago, when he last won his previous gold in the pool earlier this week, Phelps and his US teammates made sure it would be the perfect ending for one of the all-time greats.

"Getting off the bus and walking into the pool tonight, I almost felt myself starting to cry," Phelps said. "Last warm-up, last time putting on a suit, last time walking out in front of thousands of people representing my country. It's insane.

"This is how I wanted to finish my career. I held back a little bit on the podium but there were some (tears) that were popping down.

"It just feels good to know that the hard work did pay off and I was able to fight through some of the times that I went through the last two years and get back to where I actually wanted to be."

All the Rio Olympics stories you need in one place

The gold medal for the US looked like it was never in doubt after Ryan Murphy, spurred on by Phelps, gave his team the lead with a world record 100m backstroke leg, timed at 51.85 seconds.

However, Great Britain's Adam Peaty, who has set world records of his own at the Rio Olympics, overtook Cody Miller in the breaststroke to increase the tension, but on hindsight that was perfect for Phelps.

Knowing that a perfect leg was needed in the butterfly, Phelps produced just that, swimming it in 50.33s to give US the lead again. Nathan Adrian made no mistake in the freestyle as the US team gave Phelps the perfect send-off.