Under the lights at Arthur Ashe Stadium, Wawrinka jumped out to a quick one set lead, rallied to win the second set after trailing 4-1 and advanced to the quarterfinals to face fifth seed Daniil Medvedev when Djokovic called it quits after three games in the third set.
Wawrinka bests ailing Djokovic, world number one pulls out in third set
The fourth game of the opening set saw Djokovic with the first chance, taking Wawrinka to deuce, the Swiss overcoming a pair of double faults to hold with an ace for 2-2.
The next game brought up three break chances for Wawrinka after Djokovic pushed a backhand wide. After bypassing the first chance, he grabbed the second when the Serb netted a forehand.
Falling behind 15-40, Wawrinka slammed down three straight aces en route to a crucial hold for a 4-2 advantage. His next service game was capped with an ace and he closed out the set on his first attempt.
Djokovic got the quick start he was looking for, sandwiching a couple of easy holds around a break in the second game, Wawrinka missing a couple of backhands to hand the top seed a quick 3-0 lead.
The Swiss began to tire and Djokovic was getting the better of the longer rallies as he built a 4-1 advantage. Wawrinka would hit back, ripping a stunning backhand down the line to set up 15-40 and he summarily broke after an epic 30 shot rally, Djokovic netting a forehand.
The Serb was in all sorts of trouble and needed a stunning volley to stave off yet another break point to inch ahead again 5-4. It wouldn't be long until Wawrinka broke again, his power forcing weak replies en route to a 6-5 lead.
Serving for the set, Wawrinka held emphatically to take a commanding lead and his place in the last eight was confirmed when Djokovic double faulted to hand the Swiss the break in the third game of the third set.