MASON, Ohio (AP) Novak Djokovic smacked his racket on the court after losing serve, seemingly headed for another unexplainable loss at a tournament that has eluded him. In the end, he stopped fuming and started playing like the best.

The top-ranked Serb rallied from a 3-0 deficit in the final set to a 6-4, 2-6, 6-3 victory over David Goffin on Thursday, reaching the quarterfinals of the Western & Southern Open.

Third-seeded Andy Murray also needed a late surge. He recovered from a 5-2 deficit in the third set, survived a match point, and pulled out a 4-6, 7-6 (3), 7-5 victory over Grigor Dimitrov in a match that lasted 2 hours, 58 minutes.

Serena Williams moved on to the quarterfinals as well, losing only two games in her lopsided match. She's the tournament's defending champion.

Djokovic has never won Cincinnati. He's trying to become the first player to win all nine ATP Masters events in a career.

''It was a solid first set, but whatever happened in the next 45 minutes - I don't want to remember it,'' Djokovic said. ''I wasn't on the court. You know, I just lost the intensity and concentration. Luckily for me, I managed to bounce back, dig myself out of this hole I was in.''

With things falling apart in the second set, Djokovic slammed his racket three times, drawing a warning. And it kept getting worse against Goffin, a 24-year-old Belgian who is 1-20 against top-10 players. Finally, Djokovic pulled himself together and pulled it out.

Djokovic will face fifth-seeded Stan Wawrinka, who beat him for the French Open title. Wawrinka pulled out a 6-7 (2), 7-6 (5), 7-6 (5) win after Ivo Karlovic double-faulted on match point.

Murray beat Djokovic to win the title in Montreal on Sunday. He'll play Richard Gasquet in the quarterfinals as he tries to become the seventh man to win Montreal and Cincinnati back-to-back.

Like Djokovic, he needed a fast finish to keep going.

''You see Novak's match earlier today, he gets a couple of breaks and it's not impossible to get back in there,'' Murray said. ''There were many, many important points in that match. I'm not quite sure how I managed to get through it.''

Eighth-seeded Rafael Nadal lost to fellow Spaniard Feliciano Lopez 5-7, 6-4, 7-6 (3). Nadal, coming off a rain-delayed match that ended at 12:43 a.m., fell behind 3-1 in the third-set tiebreaker and never recovered.

''I was there during the whole match with the right intensity, with the right attitude, doing the things that I have to do, trying to be more aggressive, trying to go to the net more often,'' Nadal said. ''That's what I did. But today I played against an opponent that played a fantastic match.''

Lopez will play Roger Federer, the six-time tournament champion who beat Kevin Anderson 6-1, 6-1 in only 55 minutes to reach the quarterfinals.

''It's a pleasure to play that way because it doesn't happen very often that you feel this good,'' said Federer, who had only eight unforced errors.

On the women's side, Williams needed only 54 minutes to beat Karin Knapp 6-0, 6-2. She lost just 12 points while winning the first nine games.

Williams, the defending Cincinnati champion, is using the tournament as a final tuneup for the U.S. Open, where she'll try to complete a calendar Grand Slam sweep. Her quarterfinals opponent is Ana Ivanovic, who beat Sloane Stephens 2-6, 6-4, 6-1.

Williams beat Ivanovic in straight sets to win her first Cincinnati title last year.

''It will be a really good match for me and kind of test where I am, you know, just in general,'' Williams said. ''Yeah, so I look forward to that.''

A right forearm injury forced Swiss teen Belinda Bencic to withdraw after she dropped the first set against seventh-seeded Lucie Safarova. The 12th-seeded Bencic said she didn't think the injury was very serious, but it was too soon to know if she could play in next week's tournament at New Haven, Connecticut. The 18-year-old said her forearm has been sore for some time.

Bencic was coming off the biggest moment of her brief career. She upset Williams in the semifinals at Toronto last week and went on to win the tournament.

Victoria Azarenka became the fourth woman to withdraw from the tournament when she had to quit her evening match against Anastasia Pavlyuchenkova because of an injured upper left leg. It bothered her as she won the first set 6-1, and she quit three games into the second set.

''Such a short period of time before the U.S. Open, it's a little bit dangerous,'' she said. ''I had to unfortunately make that decision. It hurts a little bit because I have been playing so well. Obviously I felt like I had that match in control.''


AP freelance writer Mark Schmetzer contributed to this report.


Follow Joe Kay on Twitter: http://twitter.com/apjoekay