Roger Marti looked to have earned a point after cancelling out Karim Benzema's first-half penalty, but a second spot-kick, also awarded after help from the video assistant, allowed Gareth Bale to secure the victory before each side had a player sent off.
The best of the early chances fell to Levante, with Roger turning the ball against the post from a corner before Robert Pier fired over the bar after Madrid failed to clear a free-kick.
Madrid were handed their breakthrough 43 minutes in, though, when Enis Bardhi was penalised for handball after a VAR review, allowing Benzema to sweep home the opening goal from the spot.
Levante nearly equalised immediately, with Roger this time hitting the left-hand post after evading Nacho Fernandez, and Thibaut Courtois denied the forward again with a low stop moments after the restart.
But Roger finally found the net on the hour mark, sliding in front of Nacho on the sodden pitch to steer Jose Luis Morales' low cross from the left just beyond the reach of Courtois and into the right-hand corner.
However, Casemiro went to ground after Cheick Doukoure appeared to make the slightest contact with his shin with a rash attempted clearance, and Bale confidently dispatched the penalty once referee Ignacio Iglesias Villanueva was happy to let the call stand.
Nacho saw red when he earned a second booking four minutes from the end, but Madrid held out under some sustained late pressure before Ruben Rochina was also dismissed after collecting a second yellow card for dissent, despite having been substituted.
What does it mean? Madrid stumbling at an inopportune moment
The win means Madrid are back to within two points of second-place Atletico Madrid and nine adrift of leaders Barca, with only 13 games left to play.
They will be content with the victory even if a title challenge looks unlikely, but their recent form is threatening to derail their chances for silverware in other competitions, particularly with Barca visiting in the Copa del Rey semi-finals econd leg this week.
Vinicius impresses again
He may not have got on the scoresheet, but Vinicius once more looked Madrid's most dangerous attacking player here, even in some tricky conditions.
Nacho not at the races
Nacho never looked comfortable against Roger and was sent off for a clear foul on Raphael Dwamena. Madrid need Sergio Ramos back quickly.
Madrid host the Copa Clasico on Wednesday before the league meeting three days later. Levante next play on March 4, away to Leganes.