Ferrer's three-set win handed Spain an insurmountable 3-1 lead in the best-of-five tie.
But following singles win Friday by Ferrer and Nicolas Almagro, the Sunday reverse singles win was enough to hand Spain its 23rd consecutive Davis Cup home court victory.
The Spanish squad will host the United States in the September semis.
The Americans advanced Sunday with an upset of France.
Duggar sisters unveil Christian dating rules in new book
LGBT community has 'bullied the American people': Bachmann