(CNN) -- Few people like Monday mornings and for world No. 1 Novak Djokovic, his latest in Melbourne very nearly signalled the end of his quest to win a third consecutive Australian Open title.
The Serbian survived an epic fourth round encounter with Stanislas Wawrinka that stretched beyond 1.30am local time, eventually wrapping up a monumental 1-6 7-5 6-4 6-7 12-10 victory.
Djokovic ripped his shirt off to celebrate a triumph that had looked in serious doubt for nearly five exhausting hours, while his Swiss opponent departed from the court on the verge of tears.
It keeps alive the 25-year-old's hopes of becoming the first man in the Open era post 1968 to record a successive hat-trick of titles in Melbourne, in a match that had echoes of his 2012 final win over Rafael Nadal.
"It's hard to find the words," a drained Djokovic said in an on court interview. "He deserved, equally, to be a winner of this match. I give him a lot of credit and respect.
"He was the aggressive player on the court, I was just trying to hang in there. It's midway through the tournament but it feels like a final to me. This means a lot to me, and to him.
"Incredible that so many people stayed until nearly two in the morning. It brings back the memories of 12 months ago with Rafa."
Wawrinka gave notice of his intent by wrapping up the first set 6-1 in just 25 minutes before normal order was resumed as Djokovic regained his composure to push into a 2-1 lead.
But Wawrinka battled hard and ensured a deciding set when he took his third set point as the fourth went into a tiebreak. After swapping breaks early in the fifth set, both men repeatedly retained their serve as the epic match pushed into the early hours of Monday morning.
Djokovic held to move into an 11-10 lead and then carved out two match points in the 22nd game of the decider. Wawrinka saved two but it proved third time lucky for Djokovic as his passing shot ended the match in front of an exhilarated crowd.
Djokovic will now face Tomas Berdych in the quarterfinal after the Czech fifth seed coolly disposed of South African Kevin Anderson 6-3 6-2 7-6.
Elsewhere, Spain's fourth seed David Ferrer cruised past Japan's No. 17 seed Kei Nishikori with a 6-1 6-2 6-4 win to set up a clash with fellow countryman Nicolas Almagro. He progressed after opponent Janko Tipsarevic retired in the second set.
In the women's draw, second seed Maria Sharapova relinquished just one game as she raced to an emphatic 6-1 6-0 victory over unseeded Belgian Kirsten Flipkens.
The Russian has dropped just five games in her four matches in Melbourne -- an Australian Open record -- and says she is loving her tennis at the start of the 2013 season.
"I love competing," she told the Australian Open's official website. "There's nothing in the world that gives you that adrenalin feel, just being in the moment of a match. There's nothing that I've done in my life that has given me that experience.
"It takes a lot to get to that moment, a feeling, whether it's pressure or nerves, excitement, it's a combination of those things, but that feeling, and getting through it and winning, beating your opponent, as an athlete."
Sharapova wrapped up the second set in just 25 minutes to set up an all-Russian quarterfinal against Ekaterina Makarova, the No. 19 seed, who knocked out fifth seed Angelique Kerber 7-5 6-4.
Kerber, from Germany, suffered with a back injury during the match helping Makarova to reach the last eight for the second time in succession in Melbourne.
Fourth seed Agnieszka Radwanska, from Poland, defeated 2008 French Open champion Ana Ivanovic, from Serbia, 6-2 6-4.
She will now face China's Li Na in the last eight after the 2011 French Open champion beat German 18th seed Julia Goerges 7-6 6-1.