The Serb world number one had to dig deep to see off 15th-seeded Wawrinka's brave challenge before prevailing 1-6, 7-5, 6-4, 6-7 (5/7), 12-10 in a draining five hour two minutes match that finished at 1:41 am local time.
Djokovic somehow has to regroup for his quarterfinal on Tuesday against Czech fifth seed Tomas Berdych. Wawrinka, the Swiss Davis Cup partner of Roger Federer, produced arguably his finest match to take the three-time Australian Open champion Djokovic to the brink in a desperately-fought 104-minute final set.
Wawrinka had lost his last 10 encounters with Djokovic going back to 2006 but he produced 69 winners and seven service breaks to have the Serb in deep trouble at times during the epic match.
But Djokovic was ultimately able to reach his 15th consecutive Grand Slam quarterfinal and take his career five-set record to 18-6. Wawrinka stunned the world number one with three service breaks to capture the opening set in just 25 minutes.
Djokovic broke Wawrinka's opening service in the second set but the shocks continued when the top seed was broken for the fourth consecutive service game to level.
The Swiss, serving powerfully, fought off a break point to crucially hold serve in the third game and keep the pressure on Djokovic.
Djokovic, who had trouble keeping his footing during rallies, changed his shoes, but it mattered little as Wawrinka broke serve for the fifth straight time with a ripping backhand.
The Swiss was in the zone at 4-1 and could do little wrong as Djokovic probed for a way back into the match. But the first chinks appeared when Wawrinka was broken serving for the second set as Djokovic began to get more into the play.
Wawrinka lost his serve for the third time in the set with a netted forehand and Djokovic served out to level the match. Djokovic played an unbelievable point to break Wawrinka's first serve of the third set and the Serb celebrated extravagantly on the way back to his courtside chair.
The Swiss broke back in the next game but was broken in the ninth game with a powerful forehand and Djokovic served it out for a two sets to one advantage with the tide turning his way.
But Wawrinka, troubled by groin and hamstring soreness, again rallied and slugged it out with the top seed without a break in serve as the fourth set went to a tiebreaker.
Despite an inferior tiebreak record, the Swiss fought to three set points and sent the match into a fifth set with a titanic 21-shot rally on the third set point to send the Rod Laver Arena crowd into uproar.
Wawrinka edged ahead in the deciding with a break of Djokovic's opening service, only to give it back in another fiercely contested next game.
Games went with service for the next 19 games until Djokovic finally got a look at match point, and claimed victory on his third match point as Wawrinka fought to the bitter end. – Sapa-AFP