Joseph Schooling won the men's 100 metres butterfly final yesterday to secure Singapore's first Olympic gold medal, and deny Michael Phelps a 23rd in the last individual race of the American's extraordinary career.
Phelps, the defending champion and world record holder who is heading into retirement - again - after Rio, finished second in a three-way dead heat with two of his greatest rivals - South Africa's Chad Le Clos and Hungary's Laszlo Cseh.
Astonishingly, all three touched out in 51.14 seconds, behind Schooling's Olympic record 50.39 in the second dead-heat in a final in two days.
"I'm just ecstatic. I don't think it has set in yet. It's just crazy," said Schooling.
Phelps, who now has 27 medals, had been hoping to win the event for the fourth successive games but his Midas touch deserted him and he had to settle for a medal of a different colour for the first time in Rio.
His tally now reads 22 golds, three silvers and two bronzes. He has one event remaining, the 4x100 medley relay today, before bowing out.
"I don't know if I've (ever) been in a tie, so a three-way tie is pretty wild," said Phelps.
"I saw a second next to my name and then I looked up again and I looked over at Laszlo and Chad and hey, we all tied. We're all second that's kind of cool.
"It's kind of special, and a decent way to finish my last individual race. Can't complain too much," he said.
Le Clos, who lost his 200m butterfly title to Phelps on Tuesday, failed in his bid to turn the tables but was happy not to have been beaten by him again either.
"Strange is not the right word. Need to create a new one for that," he said. "I got silver tie in London so a three way tie is crazy. Maybe in Tokyo a four way tie."
The tie, although astonishing, was not unprecedented in top level swimming.
At least year's world championships in Kazan, Russia, three women tied for 200 breaststroke bronze - Spain's Jessica Vall, Denmark's Rikke Moeller Pedersen and China's Shi Jinglin.
Two women's freestyle golds were handed out on Thursday after Canada's Penny Oleksiak and Simone Manuel of the United States recorded the same time.