Joseph Schooling claimed a historic 100m butterfly gold as three men shared silver ©Getty Images

Joseph Schooling claimed Singapore's first ever Olympic gold medal here tonight on an evening in which two of the great swimmers of Rio 2016 finally faltered - and the third triumphed like never before.

Hungary's Katinka Hosszu was overhauled by United States' Maya Dirado in a thrilling finish to the 200 metres backstroke before Michael Phelps missed out on a 23rd gold medal and was forced to settle for silver in the first three-way tie in Olympic swimming history.

But America's golden girl Katie Ledecky completed the 200/400/800m treble by winning the 16-lap event in a time almost two seconds quicker than her own world record.

It was a night of close finishes, great comebacks and spellbinding drama.

First, Hosszu, winner of three gold medals here, was overtaken in the final metres of the 200m backstroke by an estatic Dirado.

The 23-year-old touched in 2min 05.99sec to win by six hundredths of a second before clasping her hand to her mouth in shock, unable to comprehend how she had managed to win.

"It's indescribable," she said. 

"That is just pure joy and surprise and excitement."

America's Maya Dirado, left, shocked Hungary's Katinka Hosszu in the 200m backstroke ©Getty Images
America's Maya Dirado, left, shocked Hungary's Katinka Hosszu in the 200m backstroke ©Getty Images

It was another brilliant night for the US, but the one blip came in the 100m butterfly.

Schooling led from start to finish to touch in an Olympic record 50.39sec and claim his country's first gold medal 68 years after their first appearance in the Games at London 1948.

Singapore became the fourth country to win a first ever title here after Vietnam, Kosovo and Fiji.

"I'm just ecstatic, I don't think it has set in yet, it's just crazy," the American-based 21-year-old admitted.

Phelps touched in 51,14, an identical time as two of his biggest rivals, South Africa's Chad le Clos and Hungary's Laszlo Cseh.

In a touching moment, all three locked arms before leaping together onto a cramped silver medal podium.

It may not have been his usual colour, but it was still a 27th Olympic medal for the great American.

Schooling was then fittingly presented with gold by Singaporean International Olympic Committee member Ser Miang Ng.

After two shocks the omens were pointing towards a defeat for Ledecky, but the realistic prospect of this ever happening was remote.

She duly romped away from the field to win by over 10 seconds in a world record 8:04.79 to take her third individual and fourth overall gold.

Jazz Carlin claimed British silver in 8:16.17 and there was bronze for Boglarka Kapas of Hungary in 2:16.37.

Katy Ledecky decimated both her rivals and the world record to win the 800m freestyle ©Getty Images
Katy Ledecky decimated both her rivals and the world record to win the 800m freestyle ©Getty Images

Ledecky becomes just the third person to retain her Olympic title in this event after two other Americans, Los Angeles 2024 vice-president Janet Evans and Brooke Bennett. 

"I had a lot of fun tonight, I just wanted to push myself and see what I could do," said Ledecky.

"It was my last Olympic race here in Rio. 

"The Olympics is the pinnacle of our sport and I have to wait four more years to have that moment again so I wanted the last one to be special."

Anthony Ervin then ensured the stars and stripes flew again, winning the men's 50m freestyle by one hundredth of a second.

He won in 21.40 ahead of Frenchman Florent Manaudou.

Ervin's team-mate Nathan Adrian snatched bronze in 21.49.