The former world junior champion landed his quadruple jump to roar back from a ninth-place finish in the short program.
"In the long program, I needed to be more aggressive," said the 16-year-old from Toronto. "I achieved that today and I'm really happy with myself."
Javier Fernandez cleanly landed two quad jumps in his free skate to edge his training partner and friend Yuzuru Hanyu and become the first Spanish men's champion.
"I'm so lucky because I come from Spain and we don't have this history," the 23-year-old Madrid native said. "I'm trying to grow the sport in Spain as I'm trying to grow myself in this sport."
Both Fernandez and Hanyu train with Nguyen in Toronto under Canadian coach Brian Orser.
Hanyu, who edged Canada's Patrick Chan to win Olympic gold last year in Sochi, had little time to prepare for the world championships after undergoing surgery on his bladder in late December and then promptly spraining his ankle when he returned to practice in February.
He was away from Orser, and his training base in Toronto as he recovered at home in Japan.
Though his artistry hadn't suffered from the two months away, his timing was noticeably off on his jumps, particularly the difficult quads. Both Hanyu and Fernandez fell on quad jumps in their free skate programs, but the Spaniard landed two others while the Japanese skater doubled his quad Salchow.
Fernandez scored 273.90 to top Hanyu by less than three points. Kazakhstan's Denis Ten took the bronze. Jeremy Ten of Vancouver was 22nd.
Hanyu said he was thrilled for his training partner.
"We've been competing together for a long time and always Javier told me, 'Congratulations, I'm so proud of you' (when I won) and now I'm in the opposite position," Hanyu said. "Now I realize how happy you feel when your teammate makes such a good result, so I'm very proud of him."
Fernandez said he's not only put in the training time on the ice, he also has a new relationship that has provided him with valuable perspective on competing at the top level — he's dating two-time world champion Miki Ando of Japan.
In the women's event, Elizaveta Tuktamysheva of Russia wrapped up the most successful season of her promising young career by winning the women's gold by more than 15 points over Satoko Miyahara of Japan.
Alaine Chartrand of Prescott, Ont., was 11th, while Gabrielle Daleman of Newmarket, Ont., was 21st.
"Pretty much every performance I do I feel I could do better," Chartrand said. "But today was not the performance I wanted. It didn't flow as well as in the short and that caused some mistakes."
The Canadian team headed home with two medals — Meagan Duhamel of Lively, Ont., and Eric Radford of Balmertown, Ont., won gold in pairs, while Kaitlyn Weaver and Andrew Poje of Waterloo, Ont., claimed bronze in ice dance.
— With files from The Associated Press.