Canada's Felix Auger-Aliassime nearly blew a two-set lead before ousting Spain's Roberto Bautista Agut in the third round of the men's draw.

The 12th-seeded Aliassime had his serve working for him early and often to reach the fourth round at Flushing Meadows for the second year in a row.

He opened the match with back-to-back aces, then finished the first game with a third to hold serve and go up 1-0.

The Montrealer had five aces in total in the first set, and 15 through two, but gave back the next two sets before pulling off the victory in three hours 55 minutes.

Auger-Aliassime fired 27 aces in the five-set thriller, while Bautista Agut had just two.

Unforced errors by Auger-Aliassime kept 33-year-old Bautista Agut hanging around, with the Canadian making 74 compared to 31 for his opponent.

The 21-year-old Canadian will play either American Frances Tiafoe or fifth-seeded Russian Andrey Rublev in the next round.

Meanwhile, Canadian teenager Leylah Fernandez recorded the biggest win of her young career, upsetting No. 3 seed and defending champion Naomi Osaka in the third round of the U.S. Open.

The 18-year-old from Laval, Que., came from a set down to beat Osaka 5-7, 7-6 (2), 6-4 on Friday, pulling off a shocker to advance past the third round of a Grand Slam for the first time.

The 23-year-old Osaka had won 16 straight Grand Slam matches and was holding serve for a straight sets victory before 73rd-ranked Fernandez broke the two-time U.S. Open champion for the first time forcing a tiebreak.