MONACO - An erratic Novak Djokovic suffered a surprise 6-3, 4-6, 6-2 defeat against Daniil Medvedev in the Monte Carlo Masters quarterfinals Friday.

The 10th-seeded Russian was appearing in the last eight of a Masters tournament for the first time but was not overawed. In fact, it was Djokovic who made the most mistakes. The two-time champion looked out of sorts in windy conditions and produced 47 unforced errors.

After failing to serve out the match, when his Serbian opponent broke back to 5-2 down, Medvedev broke for the fifth time to seal a memorable victory. Djokovic double-faulted at 30-30 to give Medvedev his first match point and a backhand winner secured a first win against his top-ranked rival at the fourth attempt, and a first victory against a No. 1.

He next faces the unseeded Dusan Lajovic, who also reached a Masters semi for the first time when he beat Italian qualifier Lorenzo Sonego 6-4, 7-5.

Lajovic has not dropped a set at the clay-court event and is more surprised than anybody. “I didn’t expect this. I was sick before the tournament and taking antibiotics,” the 28-year-old Serb said. “But it’s the best week of my career.”

The same goes for the 23-year-old Medvedev, who is ranked 14 and is chasing a fifth career title. He had lost the three previous matches against Djokovic, including a tough four-setter in the fourth round of this year’s Australian Open. Djokovic won that tournament to secure a third straight Grand Slam title and 15th overall, moving two behind Nadal and five adrift of Roger Federer’s record haul of 20.

But Djokovic has now failed to reach the last four in three straight tournaments, after also falling short at Indian Wells and Miami. Nadal has won at Monte Carlo a record 11 times. The second-ranked Spaniard plays the unseeded Guido Pella of Argentina later. The other match is between No. 9 Borna Coric of Croatia and No.13 Fabio Fognini of Italy.