The reigning champions set up a date with France in the quarter-finals after a nervy win over Spain