Rafael Nadal and doubles partner Marc Lopez gave Spain an unassailable 3-0 lead over Ukraine in the Davis Cup World Group play-off.
The duo beat Denys Molchanov and Sergiy Stakhovsky 6-2 6-7 (6-8) 6-3 6-4 to ensure five-time champions Spain stay in the elite top 16 nations next year.
The Czech Republic have an unassailable 3-0 lead over Argentina, reaching their third Davis Cup final in five years.
Canada won the doubles to lead Serbia 2-1 in the other World Group semi.
Nadal had not played Davis Cup doubles since 2005.
It was the 27-year-old's third best-of-five sets match since his 13th Grand Slam title in New York on Monday.
But the Majorcan said that having made the effort to come and play in Spain after the rigours of his US Open campaign, it was only a small extra demand to play in the doubles.
Nadal said: "We had the match under control, but at the start of the second set I had a bit of a slump.
"But we got the breaks in the third and fourth sets at the right moment and were able to finish the match off.
"We are still in the World Group and I think that a country with so many players in the top 100 deserves it."
Tomas Berdych and Radek Stepanek put defending champions Czech Republic into the Davis Cup final by beating Argentina's Carlos Berlocq and Horacio Zeballos in the doubles on Saturday.
World number five Berdych and US Open doubles champion Stepanek won 6-3 6-4 6-2 to book a place in the final against either Canada or Serbia.
Canada took a 2-1 lead against Serbia when Daniel Nestor and Vasek Pospisil beat Ilija Bozoljac and Nenad Zimonjic 6-7 (6-8) 6-4 3-6 7-6 (7-5) 10-8 in Saturday's doubles.