Substitute Gareth Bale rolled home the winning penalty as Real Madrid recorded a 2-1 victory at Levante.
Both of Madrid's goals came from the penalty spot, with the first correctly awarded following a VAR review and the second surviving such a review despite an apparent dive by Casemiro.
Roger Marti had struck a fine equaliser for Levante after Karim Benzema's spot-kick opened the scoring but on a night when Roger also struck both posts, the hosts left empty-handed.
It was not all good news for Real though, as they finished the match with 10 men after Nacho collected a second yellow card four minutes from time.
It may have taken VAR intervention but there was little question about Madrid's first penalty, which came minutes before the break when Enis Bardhi raised an arm to block a corner.
He may have been protecting his face but his arm was clearly in an unnatural position and the referee pointed to the spot after watching the replay, with Benzema making no mistake from 12 yards.
Levante took out their frustrations on a post at the other end as, two minutes later, Roger saw his shot come back off the left upright.
It was the second time Roger had found a post, having struck the other in the 23rd minute with a close-range effort.
It was Madrid's turn to hit the frame of the goal in the 56th minute when Benzema's header found the crossbar, and Levante took full advantage as they equalised on the hour when Marti finally found the space between the two posts with a powerful effort.
Madrid were quickly back on top, with Luka Modric and Vinicius threatening, but there was an element of fortune about the penalty which came their way in the 78th minute.
Any contact between Cheick Doukoure and Casemiro was minimal but the Brazilian went down, and the officials studying the replay let the decision stand.
Bale, on as a 74th-minute substitute, cheekily rolled home his spot-kick after a stuttering run up saw Aitor Fernandez go the wrong way.
Tensions were high, with Nacho seeing red after a tug on Raphael Dwamena off the ball.
Moments later, Levante's Ruben Rochina - who had been booked before being substituted - was sent off from the bench for his complaints at the officials.
When all the drama was over, Madrid came away with the three points, cutting their deficit to leaders Barcelona to nine ahead of next week's El Clasico.