BARCELONA, Spain -- Cristiano Ronaldo scored his Spanish league-leading 25th goal to give Real Madrid a lacklustre 1-0 win at Malaga on Saturday, when the pacesetters extended their unbeaten run to 30 consecutive matches in all competitions.
Diego Costa made sure Atletico Madrid stayed within three points of its crosstown rivals by scoring his 22nd league goal of the season in a 1-0 win at home over Espanyol.
Ronaldo netted the winner in the 23rd minute, and a tired Madrid was fortunate Malaga failed to muster a comeback after pushing the visitors into their area for the final 10 minutes.
Third-place Barcelona will enter Sunday's match against Osasuna seven points behind Madrid with the two powerhouses set to clash in the Spanish capital next weekend.
Madrid's win was tarnished by the loss of Karim Benzema to a right thigh injury after colliding with Ronaldo in the first half.
"We suffered, above all in the second half," Madrid midfielder Xabi Alonso said. "They pressed us and it was tough for us to move the ball. These are three important points. There are 10 games left and we have to play each one like it's the last."
Elsewhere, Rayo Vallecano beat Almeria 3-1 to provisionally escape the relegation zone with a third consecutive victory, while Celta Vigo earned an entertaining 1-0 win at Levante.
The opening stage of the match at La Rosaleda Stadium saw a vibrant back-and-forth exchange before Ronaldo put Madrid ahead with a wonderful solo effort.
The Ballon d'Or winner looked to be hemmed in by two defenders on the edge of the area, but he took three touches to his right and lashed a bouncing strike beyond goalkeeper Willy Caballero. Ronaldo's goal gave him 39 goals in 36 games in all competitions this campaign.
Ronaldo went close twice more shortly after, first being blocked by Caballero and then sending Gareth Bale's lobbed pass into the side netting before he ran into Benzema.
Benzema was treated on the sideline by team doctors before he asked to be substituted, ceding his spot to Angel Di Maria, in the 31st.
Former Malaga standout Francisco "Isco" Alarcon, who joined Madrid this summer, wasted a golden chance in the 51st when he sent the ball sailing high after Di Maria set him up for a one-on-one with Caballero. Isco was applauded by his former fans when replaced by Jese Rodriguez less than 10 minutes later.
Madrid, so dominant in the first half, lost control of the ball and Malaga tilted the match in its favour led by tireless forward Nordin Amrabat. But defender Sergio Sanchez blasted his team's most promising opportunity to level high in the 76th.
"This team is consistent game after game," Madrid coach Carlo Ancelotti said. "We are ready for the clasico."
But before receiving fierce rival Barcelona, Madrid hosts Schalke on Tuesday with one foot in the Champions League quarterfinals after winning their first meeting 6-1.
The first half at Vicente Calderon Stadium was ruled by the defences and featured a good save each by Atletico's Courtois Thibaut and Espanyol's Kiko Casilla.
Diego Costa broke through in the 55th when he received a throughball from David Villa, easily fended off Diego Colotto's timid attempt to slow him down, and fired the ball past Casilla.
Courtois took a hard hit to the head when Jhon Cordoba inadvertently kneed him, but the Belgian recovered and four minutes later in the 77th David Lopez's bouncing strike struck his head before falling wide of the post.
"Espanyol played a great game and complicated our lives a lot," Diego Costa said. "But that just makes us stronger."
Rayo won thanks to Joaquin Larrivey's double after Alberto Bueno headed in the opener. Fernando Soriano scored for Almeria.
Rayo rose three points above danger. Almeria was left in the drop zone along with Valladolid and Real Betis before they play on Sunday.
Celta forward Manuel "Nolito" Agudo scored from a well-orchestrated counterattack in the 19th. David Barral missed a penalty for Levante in the 61st.
The loss was Levante's first in seven straight home games. Both teams stayed in the middle of the standings.