The 36-year-old Ferrer held firm in the eighth game of the decider to save three break points and then pounced at 5-5 to secure the break before serving out for victory.
Spain will meet France in the semis after the holders reached the last four for a third year in a row after Lucas Pouille came back to beat Fabio Fognini 2-6 6-1 7-6(3) 6-3 in Genoa to clinch their tie with Italy 3-1.
Croatia also made it into the last four as Australian Open runner-up Marin Cilic crushed Kazakhstan's Mikhail Kukushkin 6-1 6-1 6-1 to seal their tie 3-1.
Croatia will meet the United States in the semis in September. The U.S. sealed their place in the last-four on Saturday after victory in the doubles gave them an unbeatable 3-0 lead.
Italian Fognini missed two chances to take the third set against Pouille, failing to serve out at 5-4 and then wasting a break point in the 11th game, prompting him to smash his racket in frustration.
French number one Pouille overpowered Fognini in the tie-break before comfortably sealing the fourth set.
"I am very proud of the team and I am really relieved because the last match was so close," France captain Yannick Noah told the competition's official website.
"It came down to a few points in the third set. I think we have been a little lucky but it’s part of the process and we enjoy our luck."
(Reporting by Richard Martin; Editing by Toby Davis and Pritha Sarkar)
