Rafael Nadal kept Spain's Davis Cup Finals hopes alive against Russia, before Marcel Granollers and Feliciano Lopez completed the comeback to give the hosts a 2-1 win in Madrid on Tuesday.
Granollers and Lopez's doubles rubber, in which they defeated Karen Khachanov and Andrey Rublev 6-4 7-6 (7-5), finished close to 2am local time at the Caja Mágica.
The top-ranked Nadal had earlier defeated Khachanov 6-3 7-6 (9-7) to level the series back at 1-1 after Rublev had rallied to prevail over Roberto Bautista-Agut 3-6 6-3 7-6 (7-0) in the first match.
"It was a difficult situation for us," Lopez said.
"We needed this win, otherwise we could be close to being out of the tournament. Now we are in a good position to advance."
Although only one of the matches reached three sets, it took nearly eight hours to complete the whole series and Spain will be back in action against the defending champions Croatia on Wednesday evening.
In this revamped Davis Cup format which is debuting this year, teams play only two singles and a doubles in each tie.
The group winners will advance to the knockout stage along with the two best second-place finishers from the six groups.
"The format makes things very difficult because every mistake puts you in a position that you don't want to be," Nadal said. "And, losing that first match, we were under pressure."
Serbia's Novak Djokovic and Britain's Andy Murray will make their first appearances on Wednesday when Serbia take on Japan and Great Britain meet the Netherlands.
The GB side will then take to court again on Thursday in their final Group E clash with Kazakhstan.
On Tuesday, there was a notable victory for Canada as they beat the USA for the first time.
Vasek Pospisil edged out Reilly Opelka 7-6 (7-5) 7-6 (9-7) and Denis Shapovalov defeated Taylor Fritz 7-6 (8-6) 6-3.
The USA had won all previous 15 meetings with their North American neighbours, though they had not met since 1965.
The result for Canada followed on from their 2-1 victory over Italy and duly secured their place in the quarter-finals. They then conceded the doubles rubber due to players being injured.
The ATP doubles victors, Pierre-Hugues Herbert and Nicolas Mahut, were the ones to secure France's opening win.
Herbert and Mahut rallied to defeat Ben McLachlan and Yasutaka Uchiyama of Japan 6-7 (4-7) 6-4 7-5 in the deciding doubles match in Group A, giving top-ranked France a 2-1 victory.
The French duo squandered two match points while serving at 5-4, but capitalised on their chance at 6-5 to clinch the victory for last year's Davis Cup runners-up.
The teams were tied after Jo-Wilfried Tsonga cruised past Uchiyama 6-2 6-1 and Yoshihito Nishioka defeated Gael Monfils 7-5 6-2.
Kazakhstan also needed the doubles match to beat the Netherlands 2-1 and clinch their first away Davis Cup win since 2011.