Real Madrid celebrate a goal in a hard-fought victory over Valencia. Reuters

Real Madrid remain in first place, but the Spanish titan got a scare from Valencia on Saturday night.

In an exciting match between two top-tier La Liga clubs, Real Madrid were able to hold off Valencia, 3-2, at Estadio Mestalla.

Real Madrid got on the board in the first half when French forward Karim Benzema broke away from Valencia defenders, and found the back of the net with a clinical left-footed shot after a fine free kick assist from Xabi Alonso in the 20th minute.

The mood would change in the second half as Los Che had plenty of scoring opportunities, but simply couldn't execute.

Real Madrid, however, were able to extend their lead in the 72nd minute. Playmaker Mesut Ozil curled a corner kick, and Sergio Ramos was there to bounce a header past Diego Alves, to give Jose Mourinho's squad a 2-0 lead.

But Valencia would come back. Substitute Pablo delivered a shot that was blocked by goalkeeper Iker Casillas, but the rebound found its way to Roberto Soldado. With Casillas out of position, Soldado ripped a shot past the Real Madrid defenders to cut the lead in half.

Minutes later, Valencia was victimized by Portuguese star Cristiano Ronaldo. Alves sprung off his line in an attempt to cut off a lob from Pepe intended for Ronaldo, but Alves lost the challenge to Ronaldo, who took advantage of the empty net by slotting in a shot past retreating Valencia defenders.

Ronaldo would lay on his back in celebration, while Mourinho would jump on the back of reserve Jose Maria Callejon, who was warming up on the sideline.

The 3-1 lead was short lived as Pablo and Soldado would link up again. Pablo did an excellent job of keeping the ball from going out of bounds along the goal line, and in the process found Soldado, who delivered a volley that cut the deficit in half.

That would be all the scoring that was left, as Valencia couldn't level the match in the dying moments.

Real Madrid needed the victory to stay ahead of Barcelona, who thumped Real Zaragoza, 4-0. Valencia are still in third place despite the loss.

Los Che will face Racing Genk on Wednesday in an important Champions League group-play match. Real Madrid, who have already qualified for the knockout stage, will host Dinamo Zagreb on Tuesday.

Next week, Real Madrid host local rival Atletico Madrid in a La Liga match.