Feliciano Lopez's heroics were in vain as the Russian Tennis Federation eliminated holders Spain from the Davis Cup Finals and helped Novak Djokovic's Serbia reach the quarter-finals.

Forty-year-old Lopez, now ranked 106, thrilled a partisan crowd in Madrid by beating world number five Andrey Rublev 2-6 6-3 6-4 to give Spain hope of making the last eight despite the absence of Rafael Nadal and Carlos Alcaraz.

Daniil Medvedev pulled the Russian team level with victory over Pablo Carreno Busta, setting up a deciding doubles rubber that determined more than just the winners of Group A.

With Sweden already guaranteed one of the two places available to best-placed runners-up, one of the big guns of the competition were certain to be knocked out.

Spain had to win the doubles and Lopez and Marcel Granollers took the opening set but Aslan Karatsev and Rublev fought back to win 4-6 6-2 6-4.

The Russians will take on Sweden on Thursday while Serbia face Kazakhstan, also in Madrid, on Wednesday.

Germany's big victory over Serbia on Saturday left them well placed in Group F but they still had to beat Austria in Innsbruck, and they suffered an early setback when Jurij Rodionov beat Dominik Koepfer.

But Jan-Lennard Struff pulled them level by beating Dennis Novak and the doubles duo of Kevin Krawietz and Tim Puetz completed the job.

In the last eight, Germany will try to reverse their result from two years ago against Great Britain, who also came from behind to defeat the Czech Republic 2-1.

Kazakhstan, who have overachieved in the competition over the last decade, defeated Canada to book their spot in the knockout stages while Croatia were 2-1 winners over Hungary despite more heroics from world number 282 Zsombor Piros, who defeated former US Open champion Marin Cilic.

The United States headed home without a victory after losing 2-1 to Colombia. Frances Tiafoe won an epic battle with 21-year-old Nicolas Mejia but Daniel Elahi Galan defeated John Isner in a deciding tie-break to end American hopes of progressing.