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.
Florida bear attack: Black bear mauls woman's face
Toddler uninjured after being knocked over by Obama family dog