Rio de Janeiro - Michael Phelps swept to a jaw-dropping 22nd Olympic gold Thursday as China's Chen Xinyi failed a doping test to cast a shadow over the Rio swimming competition.
While Phelps became one of only three athletes to have won titles in the same individual event at four straight Games, Chen tested positive for a diuretic, the Chinese Swimming Association told state media.
There was a stunning upset in the women's competition as Australian world record-holder Cate Campbell inexplicably flopped in the 100m freestyle which ended in a dead heat for gold, but there was no escaping Phelps as he romped to his fourth gold of the Rio Olympics.
The record-breaking American stormed to victory in the 200m individual medley to match his London tally four years ago.
Competing in his fifth and final Olympics, Phelps joined Al Oerter in the discus (1956-68) and Carl Lewis in the long jump (1984-96) as the only members of the exclusive four-in-a-row club.
Phelps utterly dominated a final which crackled with tension and brought the curtain down on his 12-year rivalry with fellow American Ryan Lochte.
After a strong start from local favourite Thiago Pereira, Phelps took charge on the backstroke leg before powering away to win in one minute, 54.66 seconds - almost two seconds clear of Japan's Kosuke Hagino in second.
Hagino, who won the 400m medley last weekend, produced a quick finish to pinch silver in 1:56.61, with China's Wang Shun coming through for a surprise bronze in 1:57.05.
Lochte, a six-time Olympic champion, could only finish fifth, while Pereira faded badly and he trailed home seventh.
A little more than half-an-hour later, having collected his gold medal, Phelps returned to qualify fifth fastest for Friday's 100m butterfly final - another event he won in Athens, Beijing and London.
"It's been a hell of a career," said Phelps, who could still equal his Athens tally of six gold medals, two shy of his epic Beijing haul.
"It's crazy to think about but It's also really cool because I've been able to do everything that I ever wanted," he added.
"It all started as just a kid who wasn't afraid. My body doesn't feel like an 18 year old now. It's more painful getting out of the pool. But it's just as sweet standing on the podium hearing your national anthem play. That's something I will miss."
Campbell turned 0.12 inside her own world record before being caught by the two women on either side of her - American Simone Manuel and Canadian schoolgirl Penny Oleksiak, who shared gold in a 52.70sec dead heat.
Sweden's Sarah Sjostrom also crept by her to take bronze to complete her collection after winning gold in the 100m fly and silver in the 200m free. Campbell, incredibly, finished outside of the medals in fourth.
Manuel became the first American woman to win the 100m free since the 1984 Los Angeles Games, which was also a tie - between compatriots Nancy Hogshead and Carrie Steinseifer.
"When I hit the wall I was just trying to catch my breath," said 16-year-old Oleksiak after becoming the first Canadian to win four medals in a single Games.
"I saw Simone's name and I thought I came second, then I saw 'Olympic record' by both names and I thought: 'That's crazy, no one ties at the Olympics.'" Japan's Rie Kaneto blazed to gold in the women's 200m breaststroke, clocking 2:20.30 to deny two-time doping offender Yulia Efimova.
The Russian, whose participation has provoked open hostility from rival swimmers, was a distant second with China's Shi Jinglin third.
American Ryan Murphy completed a Rio double after bullying world champion Mitchell Larkin in the men's 200m backstroke, winning in 1:53.62 to underline US dominance of the event.
Australian Larkin, who failed to medal in the 100m, took silver and Russia's Evgeny Rylov the bronze.