Popyrin enjoyed a positive build-up to the US Open, claiming his maiden ATP Masters 1000 title in Montreal earlier this month.
The Sydney-born player was brimming with confidence as he manoeuvred his way through the first set, fending off five break points before striking at 4-4 and serving it out.
He looked even better in the second, steadily going about his work and winning 88% of points on his first serve as Djokovic continued to falter.
The 24-time major winner finally burst to life at the beginning of the third set, winning the first three games before a blip allowed Popyrin to break back.
But Djokovic was quick to respond and animatedly demanded more noise from the lively crowd on Arthur Ashe Stadium as he restored his advantage and broke for a third time to keep his title defence alive.
Djokovic was aiming to win a fifth US Open that would have moved him past Margaret Court and take sole ownership of the all-time record for the most Grand Slam singles titles.
The pair continued to go toe-to-toe in set four, but Popyrin landed Djokovic in deep trouble when he he successfully converted his fourth break point in the fifth game.
He held firm in his next service game, too, saving two break points before a series of double faults and careless errors from the usually clinical Djokovic moved the 28th seed to the brink of a seismic victory.
With a double break behind him, Popyrin failed on his first attempt at serving out the match but he was more successful the second time around, landing three huge serves before Djokovic pushed the first match point long.