Williams was widely expected to brush aside 19-year-old Andreescu, playing in her first grand slam final, to bring up her record-equalling 24th major title.
But, for the fourth time of asking since she returned to the sport after giving birth, Williams fell at the final hurdle, Andreescu shocking a packed and partisan Arthur Ashe Stadium with a 6-3 7-5 win.
Williams had lost acrimoniously at the same stage here last year to Naomi Osaka, as well as in the last two Wimbledon finals, as she desperately attempts to match Margaret Court's all-time record.
The American's footwork, and her first serve, deserted her for most of the match until, at 5-1 down in the second set and facing championship point, she mounted an unlikely comeback.
But Andreescu, who was not even born when Williams won her first US Open title in 1999, stood up to her illustrious opponent and held her nerve for a famous win.
The youngster has enjoyed a rapid rise, climbing from 208 in the world this time last year, when she lost in qualifying, to a projected place in the top five.
Andreescu is now the first Canadian grand slam champion and the first woman to win here on their main draw debut.
With her close friend Meghan, Duchess of Sussex, watching with her mother, husband and coach, Williams began well enough with an ace, but successive double faults at deuce gave Andreescu a break in the opening game.
A fierce exchange of volleys at the net was won by Williams and seemed to wake her up as she got on the board for 2-1.
But, by the time the score reached 4-2, Andreescu was the one cranking up the pressure and, as one winner flashed past, Williams turned to her box, swinging her racket in frustration.
Williams somehow survived five break points and in the next game forced one of her own.
Andreescu wriggled out of that with an ace and then promptly broke to close out the opening set before racing into a 2-0 lead in the second.
Williams got back on serve, though, needing four break points and a lucky net chord to finally lay a glove on her opponent.
Even that did not faze Andreescu, who pounced on more misfiring serves and broke straight back.
Leading 5-1 and with the finishing line in sight Adreescu understandably tightened, Williams saving a championship point before twice breaking back as the crowd volume increased to ear-splitting levels.
At 5-5 Andreescu managed a gutsy hold and then brought up two more championship points, seizing her chance with the second of them, a clubbing forehand winner for a remarkable victory.