When Joseph Schooling first met Michael Phelps, he was just 13 years old -- a kid meeting the swimmer he idolized. Neither could have known at the time that the same young boy would go head-to-head with his idol in the pool years later.

And not only would they go head-to-head, the boy would win.

Schooling beat his swimming hero in the 100-meter butterfly in at the 2016 Rio Olympics on Friday night to win Singapore's first ever Olympic gold medal.

Phelps, who finished in a three-way tie for silver, is the three-time reigning gold medalist in that event and had already claimed four gold medals in each of the finals he swam in Rio de Janeiro.

The now 21-year-old Singaporean swam the 100 in 50.39 seconds to set an Olympic record. Phelps, South African Chad le Clos and Hungarian Laszlo Cseh each finished in 51.14 seconds.

Joseph Schooling got a hug from his idol after beating him for gold. USATSI

Even when Schooling beat Phelps in the semifinal heat Thursday, Singaporeans took to social media to celebrate his feat. One can only imagine the celebrations in Singapore now, as the race ran in the Saturday morning hours.

While Phelps was disappointed he was unable to secure his fifth gold medal of the 2016 Summer Games and 23rd of his Olympic career, he couldn't help but marvel at the young man who bested him all these years later.

"Watching Joe and what he's done over the last two years -- he's been swimming great," Phelps told NBC. "50.3 is obviously a really good time and a very respectable time. My hat's definitely off to him."

Schooling, who swims for the University of Texas, stands to receive a $750,000 bonus from the Singaporean National Olympic council. Thanks to an NCAA rules exemption for Olympic athletes, he should be able to keep all of it without risking his college eligibility, either.

If winning gold wasn't amazing enough, Schooling took down the most decorated Olympian of all time and is now $750,000 richer. Not a bad Friday night.