MELBOURNE, Australia — Novak Djokovic’s bid for a fourth consecutive Australian Open title ended in a dramatic five-set quarterfinal loss to Stanislas Wawrinka that opens up the prospects of a new major champion.

No. 8-seeded Wawrinka lost 14 head-to-heads to Djokovic until a 2-6, 6-4, 6-2, 3-6, 9-7 win on Tuesday night put him into a semifinal that very few expected against No. 7 Tomas Berdych.

Djokovic held off Wawrinka 12-10 in the fifth set in a 5-hour, 2-minute fourth-rounder that finished at 1:41 a.m. here last year — the longest Grand Slam match of the season — en route to his third straight Australian title. He and also edged Wawrinka in five sets in the U.S. Open semifinals in September.

This time, it was Wawrinka’s turn.

‘‘Last year I finished it was really tough but this year I came back it was a new year,’’ he said. ‘‘I tried everything. He’s an amazing champion. He never gives up. I’m really, really ... really happy.’’

This one took exactly four hours and featured some stunning rallies, with both players openly showing amazement at some of the shots coming back from the other side. And just to add to the drama, there was a five-minute rain delay with Wawrinka serving at 5-5 in the fifth.

Djokovic frequently held up and pinched his thumb and forefinger together to show how close the shots were to either hitting or missing the lines. The six-time major winner had to constantly serve to stay in the match after an early exchange of breaks in the fifth set and the pressure finally told.

After all the superb shot making, it was a mis-hit from Wawrinka that set up match point. Djokovic chased the floating service return to the net but skewed his cross-court drop shot too wide. He then missed a volley on match point, ending a run of 28 consecutive wins dating back to his U.S. Open final defeat to Rafael Nadal.

‘‘He took his opportunities. He deserved his big win today,’’ Djokovic said. ‘‘There’s nothing I can say. I gave it my best, I gave it my all. It wasn’t to be this time.

‘‘He showed his mental strength and he deserved to win — the only thing I can say is congratulations.’’

Djokovic hadn’t lost at Melbourne Park since 2010, when he went down to Jo-Wilfried Tsonga in the quarterfinals, and has been unquestionably the best player on Rod Laver Arena since 2011.

And he was installed as the tournament favorite immediately after the draw, when he landed on the opposite side to top-ranked Nadal, Wimbledon champion Andy Murray and 17-time major winner Roger Federer. Nadal plays 22-year-old Bulgarian Grigor Dimitrov in the quarterfinals on Wednesday, when Murray and Federer go head-to-head.

Berdych, the 2010 Wimbledon finalist, reached his first Australian Open semifinal when he beat No. 3-seeded David Ferrer 6-1, 6-4, 2-6, 6-4. Ferrer, a semifinalist here in two of the previous three years, was clearly frustrated at times, yelling at himself after points and bumping into a line judge after breaking Berdych in the sixth game of the third set.

The 31-year-old Spaniard said it was an accident in a ‘‘nervous moment,’’ as he went for his towel, saying ‘‘It was nothing ... I say to him excuse me after that.’’

He could face a sanction for coming into contact with a match official.

On the women’s side, 19-year-old Canadian Eugenie Bouchard reached the semifinals in her first trip to the Australian Open, beating Ana Ivanovic 7-5, 5-7, 6-2 to set up a showdown with two-time finalist Li Na.

Ivanovic had beaten top-ranked Serena Williams in a massive upset in the previous round, and No. 3 Maria Sharapova was also out in the fourth round. Two-time defending champion Victoria Azarenka is into the quarterfinals on Wednesday.

Bouchard, the first Canadian to reach the Australian Open semifinals, played with real composure against former 2008 French Open champion Ivanovic, who started the season with a title at Auckland, New Zealand.

That result means two-time Australian Open finalist Li, who beat Flavia Pennetta 6-2, 6-2 in an earlier quarterfinal featuring two women who’ll turn 32 next month, will have to face a teenager for the third time in the tournament.

Bouchard went to the net 24 times and won 19 of those points. She broke Ivanovic’s serve seven times, including the last game, and had to sit through a lengthy time out when she was leading 4-3 in the second set while her opponent received treatment.

‘‘It’s something I’ve been doing since I was five years old and working my whole life for and sacrificing a lot of things for, so it’s not exactly a surprise,’’ she said. ‘‘I always expect myself to do well. ‘‘

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.