Alvaro Odriozola (Getty Images)
Real Sociedad right-back Alvaro Odriozola volleyed Spain ahead on 29 minutes in Vila-real with a fantastic strike from the edge of the area in just his third international appearance.
Andres Iniesta drew a sharp save from Yann Sommer at his near post before the break, and the veteran midfielder went close again early in the second half before he was replaced to a warm ovation ahead of his move to Japan.
AC Milan defender Rodriguez levelled for Vladimir Petkovic's Switzerland, also World Cup bound, on the hour with a tap-in from close range after David de Gea palmed away an effort by Stephan Lichtsteiner.
Sommer produced another fine stop to deny Valencia forward Rodrigo, while Nacho grazed the post with a curling strike late on as Spain's unbeaten run under Julen Lopetegui stretched to 19 matches.