Sergio Ramos missed two second-half penalties on his record-breaking appearance for Spain but Gerard Moreno rescued the visitors a late 1-1 draw against 10-man Switzerland in Saturday's dramatic Nations League clash.
The captain, who earlier blocked a shot on the line, was twice foiled from the spot by Yann Sommer on his 177th international appearance, which saw him become the most-capped European male player.
Ramos' misses on his big night appeared as though it would cost Spain dear as Remo Freuler's 26th-minute half-volley put Switzerland on course for a first Group A4 victory.
But the hosts, who lost Nico Elvedi to a red card for his part in the second penalty at St. Jakob-Park in Basel, were denied in the last minute as Gerard spared Ramos' blushes and prevented Spain from falling to successive defeats in the competition.
Unai Simon was surprisingly selected in goal for Spain - the only player to retain his place from the 1-1 friendly draw with the Netherlands - and he was equal to Xherdan Shaqiri's shot from a tight angle 19 minutes in.
But Switzerland, who held Germany to a 3-3 draw last time out, did not have to wait much longer to make the breakthrough as Freuler sent Breel Embolo's cross spinning away from Simon with an impressive first-time finish.
That made it three games in a row Spain have conceded, having kept a clean sheet in the previous three, but they should have been level before half-time - Sommer keeping out Fabian Ruiz and Mikel Oyarzabal before Ferran Torres missed a sitter.
Ramos was right in the thick of the action in the second half, denying Haris Seferovic with a block on the line after Simon was left stranded a long way from goal, 92 seconds before heading the ball against Ricardo Rodriguez's arm to win a penalty.
The Spain skipper attempted to pick out the bottom-left corner but Sommer guessed the right way to push the ball past the post.
He had a chance to redeem himself when Elvedi slid in on substitute Alvaro Morata to give away another penalty, earning a second yellow in the process, but Ramos' tame attempt was a simple one for Sommer to keep out.
There was to be one more late twist, though, as Gerard met Sergio Reguilon's cross and fired past Sommer eight minutes after being brought off the bench to salvage a point for Spain.
What does it mean? Spain relinquish control of top spot
Keeping out the opposition has become an issue for Spain but scoring at the other end is arguably a bigger problem, having now netted only three goals in their last five matches.
Luis Enrique does not want to be judged until after next year's rearranged Euro 2020 finals but he fast needs to find a resolution to his side's lack of cutting edge, having managed a whopping 20 efforts against Switzerland but converting just one of them.
With one point from their last two Group A4 matches, Spain are now a point behind Germany - 3-1 winners over Ukraine in Leipzig on Sunday (AEDT) - ahead of the final-game shoot-out between the sides in Madrid on Wednesday.
It seemed almost destined that Ramos would steal the headlines for Spain on the day he overtook Italy great Gianluigi Buffon as European football's most capped footballer.
In many ways he still managed to do exactly that for the wrong reasons as he twice failed to beat Sommer, who became only the second goalkeeper to save a Ramos penalty after Croatia's Danijel Subasic in June 2016.
Reguilon to the rescue
Gerard scored with one of only four touches of the ball after being brought on as a late substitute - his fourth goal for Spain, all of them coming in the month of November (three in 2019 and one in 2020).
He was served the goal on a plate by left-back Reguilon, who had more touches (113) than any player on the field and also chipped in with two clearances, which no Spain player could match.
Spain now know they have to beat Germany in Seville on Wednesday to finish top of Group A4 and qualify for next year's finals. As for Switzerland, they trail next opponents Ukraine by three points in the battle to avoid relegation.