RIO DE JANEIRO (AP)-- Joseph Schooling was working on a school essay one morning in 2008 when Michael Phelps showed up to train at his club in Singapore ahead of the Beijing Olympics.
While other kids rushed at Phelps wanting photos, Schooling was frozen. He couldn't believe his swimming idol was in front of him. Eventually, the 13-year-old mustered the courage to get a picture, too.
"I couldn't really smile," Schooling said. "I just opened my mouth."
Their long-ago chance meeting made the rounds of social media Friday night after Schooling upset Phelps in the 100-meter butterfly to win his island nation's first Olympic gold, with the American losing the last individual race of his career. Phelps finished in a three-way tie for silver with longtime rivals Chad le Clos of South Africa and Lazslo Cseh of Hungary.
"A lot of this is because of Michael," Schooling said. "He's the reason why I want to be a better swimmer."
The youthful looking Schooling might be unknown to the rest of the world, but in swimming circles he has solid credentials. He earned bronze in the 100 fly at last year's world championships in Russia, and he owns a slew of medals from the Asian, Commonwealth and Southeast Asian Games.
The 21-year-old Schooling competes for the University of Texas, where he'll be a junior this fall. He swept the 100 and 200 butterfly at this year's NCAA championships and swam on all three winning relays for the Longhorns. He has the school's mascot and the words 'Come and take it' tattooed on his left shoulder blade.
Did he ever.
Schooling created a stir in the preliminaries, beating Phelps by 0.19 seconds in their shared heat. They swam in different semifinal heats, with Schooling winning his and Phelps getting beat by Cseh in the other.
Schooling was just getting warmed up.
He won gold in an Olympic-record 50.39 seconds, leaving Phelps, Le Clos and Cseh in his wake. The winning margin of 0.75 seconds was the largest since American Mark Spitz won gold at the 1972 Munich Games and the time was faster than Phelps' winning time four years ago in London.
"I don't think I'm anywhere close to these three guys next to me," Schooling said. "A real roller coaster ride and a real fun one, too."
Phelps steered Schooling in the proper direction during the medalists' parade around the deck, the veteran of dozens of such walks showing the newest champion the way.
"I was like, 'Dude, this is crazy,'" Schooling told Phelps. "He looked at me, he smiled and it's just, 'I know.'"
At the medalists' news conference, Phelps urged reporters to ask Schooling some questions.
"I'm proud of Joe," Phelps said. "I've been able to watch him grow and turn into the swimmer that he is."
By winning his country's first Olympic gold, Schooling earned a bonus of $1 million Singapore dollars or nearly $750,000 US. He'll have to give back $150,000 US to the National Sports Association for future training and development.
"I hope this paves a new road for sports in Singapore," Schooling said. "I hope it shows that people from the smallest countries in the world can do extraordinary things. Hopefully, it changes all of sporting culture in Singapore."
Schooling's grand-uncle Lloyd Valberg was Singapore's first Olympian at the 1948 London Games. Hearing about him as a child, Schooling told his father he wanted to compete in the Olympics.
"This race means more to my family and my friends and those people who supported me. I did this for them," Schooling said. "When you race for people bigger than yourself, I think it means a lot to accomplish what you wanted to."
AP Sports Writer James Ellingworth contributed to this report.