RIO DE JANEIRO - Joseph Schooling sensationally upset Michael Phelps in the 100m butterfly on Friday to seize Singapore's first ever Olympic gold medal at the Rio Games.

The 21-year-old Asian champion denied Olympic icon Phelps a fourth straight victory in the event, leading from start to finish to win in an Olympic record of 50.39sec. Phelps, sixth at the turn, couldn't pull off one of his trademark comebacks, but he had plenty of company on the second step of the podium as his longtime rival Laszlo Cseh of Hungary and South African Chad le Clos both matched his time of 51.14sec in an astonishing three-way tie for silver.

The only other three-way tie for Games silver came back in 1968, in the women's speedskating 500m. "It's wild," said Phelps. "Chad and I have had some races over the last four years and Laszlo and I - I can't even remember when I first raced him... so it's kind of special and a decent way to finish my last individual race."

The tie with Phelps was the closest Cseh has come to the US star in Olympic competition. In three prior Games the Hungarian had claimed five medals, all silver or bronze in races won by Phelps. Phelps's rivalry with Le Close blossomed more recently, at the 2012 London Games where the South African beat Phelps in the 200m butterfly only to fall to him in the 100m fly.

Victory in Friday's fly would have given Phelps a 14th individual Olympic title, but Schooling was too strong. He punched the water and bellowed as Phelps swam over to congratulate him.

Phelps, 31, insists he won't be back for a sixth Olympics. But after winning four golds so far in Rio -- in the 4x100m free and 4x200m free relays, the 200m butterfly and the 200m individual medley -- he'll have a shot at one more -- it would be his 23rd -- on Saturday in the 4x100m medley relay.

Schooling, meanwhile, was absorbing the enormity of his first. "It hasn't really sunk in yet. I'm full of emotions now," he said. "I don't know what to believe, whether I actually did it or I'm still preparing my race." Phelps may have been beaten, but the United States raked in plenty of gold on the penultimate night of action at the Olympic Aquatics Center.

World record for Ledecky: Katie Ledecky obliterated the field and her own world record in winning the 800m freestyle in 8min 04.79sec. The 19-year-old is the first Olympian since Debbie Meyer in 1968 to win the 200m, 400m and 800m free titles in one Games.

"The goal was 8:05 or better so I hit all my goals right on the nose this week," said Ledecky, who improved the previous record of 8:06.68 she set in January. She finished almost half a length in front of her closest rivals, silver medallist Jazz Carlin of Britain (8:16.17) and bronze medallist Boglarka Kapas of Hungary (8:16.37).

American Anthony Ervin won gold in the men's 50m free -- 16 years after tying for gold in the same event in Sydney with teammate Gary Hall jr. Defending champion Florent Manaudou of France was quick off the blocks but Ervin and teammate Nathan Adrian were close behind and Ervin powered into the wall to beat the Frenchman with a time of 21.40 to 21.41. Adrian was third in 21.49.

American Maya DiRado denied Hungarian Katinka Hosszu a record-equalling fourth individual gold in a 200m backstroke thriller. Hosszu, who set a world record in winning 400m medley gold then added the 100m backstroke and 200m medley titles, led through the first 150 meters, with DiRado clinging to her shoulder.

The American got her at the finish, with a time of 2:05.99. Hosszu, trying to join Kristin Otto as the only women to win four individual swimming golds in a single games, was timed in 2:06.05.

facts about giant-killer Joseph Schooling

First Singapore gold

Singapore had never won an Olympic gold before Schooling's breakthrough. The country first entered the Olympics in 1948. Singapore's first medal was a silver in weightlifting at Rome in 1960. Singapore waited 28 years before winning its next medal, a silver in table tennis at Beijing in 2008. In London, Singapore won two bronze medals in table tennis.

Coach quarrels

To further his swimming career, Schooling left Singapore when he was 13 and moved to Florida to train at the Bolles School, living in a boarding house with older boys. He regularly fought with his coach Sergio Lopez, the Spaniard who won a bronze medal in breaststroke at the 1998 Olympics, but credits him for his success.

Met idol Phelps at 13

Joseph Schooling met Michael Phelps by chance when he was 13 and had his photograph taken with him. Phelps was in Singapore preparing for the Beijing Olympics and was training at one of the pools where Schooling also practiced. Schooling said Phelps was his idol growing up but had no regrets about beating him in his final race.

Longhorn tattoo

Schooling bears a tattoo on his back, depicting the head and horns of a Longhorn, a breed of Texas cattle, and the emblem of sporting teams at the University of Texas, where he studies and trains. Underneath the cattle horns are the words, "Come and Take It." Schooling had to convince his parents before they allowed him to get the tattoo.