MADRID -- Rafael Nadal kept Spain's hopes alive, then Marcel Granollers and Feliciano López completed the comeback in the decisive doubles match to give the hosts a 2-1 win over Russia in the inaugural Davis Cup Finals.
The top-ranked Nadal earlier defeated Khachanov 6-3, 7-6 (7) to level the series 1-1 after Rublev had rallied to beat Roberto Bautista-Agut 3-6, 6-3, 7-6 (0) in the first match.
"It was a difficult situation for us," López 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 series at the "Caja Mágica" (Magic Box) center court. Spain will be back in action on Wednesday against defending champion Croatia. Russia beat Croatia on Monday.
In the revamped Davis Cup format debuting this year, teams play only two singles and a doubles in each tie, with the group winners advancing to the knockout stage along with the two best second-place finishers in 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."
The Davis Cup Finals is being played in World Cup-style with all 18 teams playing in a single venue in the same week. It is the result of a 25-year partnership between the International Tennis Federation and Kosmos, a group co-founded by Barcelona soccer player Gerard Piqué.
Brazil star Neymar was among the more than 12,000 in attendance, which also included a marching band organized by Spanish fans that fired up the crowd throughout the matches.
The French duo squandered two match points while serving at 5-4, but capitalized on their chance at 6-5 to clinch the victory for last year's Davis Cup runner-up.
"We know we've arrived late from London, but the captain had a lot of confidence in our team," Mahut said. "There was a lot of intensity in the win but we're really happy today. This was a really difficult tie."
"It's the end of the season but I think I played one of the best matches for sure of the year, maybe in my career," the 14th-ranked Schwartzman said. "I think Guido helped me a lot to be more confident in this match and I played unreal tennis."
KAZAKHSTAN WINS AGAIN
Kazakhstan also needed the doubles match to beat the Netherlands 2-1 and clinch its first away Davis Cup win since 2011.
The Group E victory came after Mikhail Kukushkin and Alexander Bublik defeated Robin Haase and Jean-Julien Rojer 6-4, 7-6 (2). Kukushkin had beaten Botic van de Zanschulp 6-2, 6-2, while Haase defeated Bublik 7-5, 3-6, 7-6 (5).
"I almost died there," Bublik said, jokingly.
Australia beat Colombia behind Nick Kyrgios' 6-4, 6-4 win over Alejandro González and Alex de Minaur's 6-4, 6-3 victory over Daniel Elahi Galan.
Colombia had lost to Belgium on Monday.