The San Sebastian outfit came into the game occupying the fourth and final UCL qualification spot and appeared to have taken a 12th-minute lead after David Silva won possession off Fran Garcia and Mikel Oyarzabal picked up the loose ball to curl in brilliantly, but following a VAR review, referee Alejandro Muniz deemed that Silva had committed a foul on the Rayo left-back.
The hosts continued to dominate possession as Alexander Sorloth failed to get the necessary purchase on a header from Aritz Elustondo’s cross, with the Norwegian then providing a cutback for Silva, who controlled and fired agonisingly wide.
Andoni Iraola’s men still hadn’t threatened Alex Remiro’s goal as the clock ticked past the half-hour mark, but at the other end, visiting centre-back Abdul Mumin was acquitting himself well in just his sixth start for the club, making several clearances to ease the pressure on his side.
Incredibly, it took until five minutes into the second half for the first shot on target, and it was Rayo who had the opportunity, as captain Oscar Trejo forced Remiro to palm over.
Despite being the more defensive team in the contest, the Madrid natives pounced when the next chance presented itself. Jon Pacheco slipped as he looked for options upfield, allowing Isi Palazon to steal the ball, streak clear and sweep in clinically.
However, no sooner had the deadlock been broken than it was all-square once again as Silva fed Aihen Munoz, who delivered a delicious left-wing cross for Sorloth to power home his 10th LaLiga goal of the campaign.
And the turnaround was complete on 81 minutes as a carbon-copy assist from Munoz saw Carlos Fernandez beat Stole Dimitrievski to the delivery, bundling it past the North Macedonia goalkeeper via a deflection off the unlucky Florian Lejeune.
La Real now have a six-point cushion over fifth-placed Real Betis after their 3-2 loss at Osasuna, and the two direct rivals for a top-four spot face each other on Tuesday night in Seville.
Rayo’s next assignment meanwhile is a daunting one at home to Barcelona the following day.