Novak Djokovic led Serbia into the Davis Cup semi-finals with singles and doubles victories over Kazakhstan.

Serbia sneaked into the last eight as one of the two best group runners-up thanks to Russia’s victory over Spain, and they had to come from behind again after debutant Miomir Kecmanovic lost an epic tussle against Mikhail Kukushkin.

But Djokovic comfortably saw off Alexander Bublik and he then teamed up with Nikola Cacic to beat Andrey Golubev and Aleksandr Nedovyesov as Serbia buried the ghost of their emotional quarter-final loss two years ago.

On that occasion, Djokovic and Viktor Troicki – now captaining the side – missed golden chances to win the deciding doubles against Russia, and tears flowed in the post-match press conference.

They may have sensed it may not be their night again when Kecmanovic was unable to take four match points in a 7-6 (5) 4-6 7-6 (11) defeat by Kukushkin that lasted three hours and 18 minutes.

Kecmanovic looked on the brink of victory at 5-3, 40-15 in the deciding set but Kukushkin produced some inspired play to break back and then saved two more match points in the tie-break before finally taking his fifth chance.

The 33-year-old dropped to the court in delight while Kecmanovic smashed his racket in frustration, saying afterwards: “I had some tough matches before, but this one is definitely the hardest out of them all.”

Given Djokovic’s strength, it was a vital win for Kazakhstan, and the world number one duly drew his country level with a 6-3 6-4 victory over the mercurial Bublik – an 18th singles win in a row in the competition for the 20-time grand slam singles champion.

Djokovic and Cacic lost a nail-biting doubles clash to Germany in the group stages, and the momentum was with Golubev and Nedovyesov when they hit back to win the second set, but the Serbian duo turned the tide back in their favour and clinched a 6-2 2-6 6-3 victory.

There were exuberant celebrations from the two players and Troicki, and they can look forward to a semi-final against Croatia on Friday.

Speaking on court, Djokovic said: “I’m proudest of the fighting spirit. We had a little drop energetically in the second set but we managed to bounce back. The start of the third set was crucial. I’m proud of Nikola, proud of this team and I think we deserve to be in the semi-finals.”