Late 'wardrobe malfunction' could not stop Michael Phelps winning his 21st Olympic gold medal

Michael Phelps (USA) of USA reacts after his team won the gold medal. Reuters/Stefan Wermuth

Even a late 'wardrobe malfunction' could not stop Michael Phelps from winning his 21st Olympic gold medal for the United States in the Rio pool on Tuesday.

The most medalled Olympian of all time, now with an unprecedented collection of 25, tore his swim cap in half as he was putting it on just before the start of the day's final 4x200 metres freestyle relay.

Team mate Conor Dwyer swam the opening leg and then handed over his cap, turning it inside out to avoid any conflict with rival sponsors.

Phelps wears his own MP brand made by Italian company Aqua Sphere.

"I finished my leg and he tapped me on the shoulder when I was cheering Townley (Haas) on," Dwyer told reporters. "I heard him say 'Diddy, look at my cap. I don't have a cap. So I handed him mine.

"We all have...different sponsors so I think he had to wear just an all-black cap, so we reversed it and put on.

"We've seen that guy go through a lot of adversity, from winning gold medals without goggles, so I think a different cap won't stop that guy from having a good split (time)."

Dwyer had handed over to Haas in the relay, who was then followed by Ryan Lochte before Phelps swam the anchor leg to victory.

In the butterfly final at the 2008 Beijing Games Phelps famously won gold despite swimming with water-filled goggles that left him having to count his strokes.