Oscar Trejo scored the winner with a contentious second-half penalty as Real Madrid missed the chance to return to the LaLiga summit after falling to a 3-2 defeat at Rayo Vallecano.

Carlo Ancelotti's side trail leaders Barcelona by two points after losing at Vallecas, where referee Juan Martinez Munuera and the VAR played a significant part on Monday.

Luka Modric's penalty and an Eder Militao header had put Madrid into the lead after Santiago Comesana's opener, before Alvaro Garcia equalised during a breathless first half.

Yet there was to be more drama when Dani Carvajal was deemed to have encroached as Thibaut Courtois saved a 67th-minute penalty from Trejo, who converted the retake to secure victory.

Comesana fired Rayo into a fifth-minute lead after angling a first-time left-footed shot past Courtois following Fran Garcia's whipped left-wing cross.

Martínez Munuera gave a 37th-minute penalty to Madrid after consulting the touchline monitor following a tangle of legs that saw Marco Asensio felled by Fran Garcia, with Modric coolly converting down the middle from the spot.

Militao directed a header into the bottom-left corner from Asensio's inswinging corner to give Madrid the lead, only for Alvaro Garcia to power a left-footed strike past Courtois to equalise three minutes later.

Courtois saved Trejo's penalty after Carvajal was adjudged to have handled in the second half – again following a review of the touchline monitor – but the Madrid right-back was penalised for encroachment, allowing the Rayo midfielder to find the bottom-right corner at the second attempt.

That was to prove the winner, although Madrid almost salvaged a draw when Rodrygo spurned a glorious 89th-minute chance, turning over Asensio's centre.

What does it mean? Madrid slip up again

With Liverpool confirmed as their next Champions League opponents in the last 16, reigning European and Spanish champions Madrid will have to improve both domestically and on the continent after faltering in back-to-back LaLiga games.

A 1-1 draw against Girona coupled with only Rayo's second win against Madrid in 21 LaLiga attempts will leave Ancelotti much to ponder with a game to go before November's World Cup break.

Andoni Iraola will have much to celebrate, though, despite his second-half dismissal for dissent, after Rayo won three league games in a row for just a second time under his stewardship.

Classy Comesana

Comesana appeared to be everywhere for Rayo against Madrid, scoring the opening goal with a coolly taken finish that belied his defensive-midfield position.

The Rayo man was a dominant force in the middle of the park as well, though, creating three chances and regaining possession eight times – both game-leading figures in just 79 minutes.

Defensive issues for Madrid

Madrid often relied on late fightbacks on their way to Champions League and LaLiga glory last season, perhaps masking their defensive issues.

But Los Blancos have come unstuck this term after keeping just two clean sheets in their first 13 LaLiga games, their lowest tally at this stage of a season since 2013-14 – also under Ancelotti.

What's next?

Madrid host Cadiz on Thursday in their last game before the World Cup break, while Rayo are at home to Celta Vigo on the same day.