Eight years ago, a 13-year-old swimmer from Singapore got to meet his idol, Michael Phelps.

On Saturday afternoon (NZ time), Joseph Schooling defeated the greatest Olympian in history in the final of the men's 100m butterfly at the 2016 Games in Rio de Janeiro.

Schooling, who had pipped the American in the semifinal as he became his country's first male swimmer to qualify for an Olympic final, denied Phelps his 23rd Olympic gold medal.

REUTERS Michael Phelps congratulates Joseph Schooling after Schooling won the men's 100m butterfly gold.

Phelps ended up in a three-way deadheat for silver with South Africa's Chad le Clos and Laszlo Cseh of Hungary, 0.75s behind Schooling's winning time of 50.39 seconds.

READ MORE:

* Phelps the $3-million medal man

* Rio Olympics full coverage - day seven

* Silver success for NZ women's pair rowing

* Michael Phelps wins Olympic gold No 22

* Rio commentator mixes-up Phelps with Lochte

* Phelps: the secret of cupping

* Michael Phelps' record for televised golf putt

It's a far cry from when the young Schooling had his photo taken with Phelps in 2008.

Schooling, now a student at the University of Texas, won silver in the 100m butterfly at the 2014 Commonwealth Games in Glasgow and collected Singapore's first world championship swimming medal when gaining bronze in the same event.

Phelps, 31, is the most decorated Olympian, with 27 medals, having added to his staggering tally with four gold in Rio.