Viktor Troicki defeated Aleksandr Nedovyesov 6-2, 6-3, 6-4 to give Serbia a 3-2 win over Kazakhstan and a place in the Davis Cup quarter-finals on Sunday.
Serbia, who won the Davis Cup in 2010 led by world number one Novak Djokovic, will host defending champions Great Britain in July's last-eight stage.
Sunday's decisive rubber followed a marathon match in which Djokovic battled for almost five hours to defeat Mikhail Kukushkin 6-7 (6/8), 7-6 (7/3), 4-6, 6-3, 6-2.
Djokovic hit 19 aces and 37 winners but committed 94 unforced errors in a four hour 57-minute epic win over world number 79 Kukushkin.
'This was one of the most difficult matches in my carrier both physically and mentally,' 28-year-old Djokovic told reporters after levelling the tie 2-2.
'My opponent was near a victory, he was a better player today. After the third set I did not know what would happen, but the audience pulled me up, they have me the strength.
'In the first set the two players were almost on an equal footing but Kukushkin snatched the tie-break.
Djokovic fought back with the second set tie-break but Kukushkin dug deep, moving and playing excellently to take the third set 6-4.
However, despite fatigue and shoulder pain, Djokovic appeared more fresh than his rival in the fourth set that he won rather easily 6-3 which hinted at the final outcome.
He continued the fifth set in the same rhythm for a 6-2 win to take the rubber. 'I was playing against Novak, there was a lot of emotions. He started to play much better in the fourth set, became more aggressive and served better ... I played worse in key moments,' Kukushkin, 28, said.
'He is the best in the world.'
The decisive rubber took just 1 hour and 51 minutes.
'It is important that I remained concentrated during the whole match,' Troicki told reporters.
'It will be interesting against Britain in quarter-finals. We have to select the court surface smartly,' added the 30-year-old.Djokovic gave his country a 1-0 lead on Friday by easily defeating Nedovyesov, the world number 200.
But, in the second singles, Kukushkin fought back to level 1-1 by beating Troicki 7-5, 6-2, 6-4.
In Saturday's doubles, Nedovyesov and Andrey Golubev defeated Djokovic and Nenad Zimonjic 6-3, 7-6 (7/3), 7-5.That was Djokovic's first loss in Davis Cup in five years.