With Cristiano Ronaldo missing his scoring touch, Real Madrid needed defender Pepe to score in the second half to secure a 1-0 victory at Espanyol on Sunday to pull within three points of the Spanish league co-leaders.
Pepe was left unmarked to head in Luka Modric's corner kick in the 55th minute, as Cristiano Ronaldo failed to add to his league-leading 20 goals.
Ronaldo is favoured to win the FIFA's Ballon d'Or on Monday over Lionel Messi and Franck Ribery. The Portugal forward uncharacteristically wasted two clear scoring chances, while goalkeeper Kiko Casilla denied him on another three occasions.
Third-place Madrid took full advantage of Saturday's scoreless draw between Barcelona and Atletico Madrid, which left them level at the top of the table at the league's halfway mark.
Also on Sunday, Real Betis remained in last place after slumping to an error-plagued 2-1 loss at home to Osasuna, while Rayo Vallecano won 1-0 at Getafe's foggy Alfonso Perez Coliseum to end a five-game streak without a win in league play.
Led by striker Jhon Cordoba, Espanyol surged forward at the start and almost took the lead when Cristian Stuani steered his point-blank header past the wrong side of the post four minutes in.
Madrid weathered Espanyol's initial push and turned to Karim Benzema and Ronaldo to provide the attacking threat. Ronaldo scuffed Benzema's pass in the 18th before drawing two awkward saves from Casilla with a powerful strike in the 31st and a dipping free kick in the 37th.
Espanyol, which was without suspended forward Sergio Garcia and coach Javier Aguirre, was fortunate to make it to halftime not trailing after Angel Di Maria squandered Madrid's four-on-two counterattack seconds before Benzema headed wide in the 42nd.
But Pepe made good on Madrid's dominance by thumping Modric's pass under Casilla, who got a hand on the ball but not enough to keep it out of his net.
Ronaldo had two more great looks to increase his impressive tally this season, but Casilla bettered him one-on-one in the 82nd before saving Benzema's shot in the 89th and watching Ronaldo fire the rebound wide with the goalmouth beckoning.
Nothing went Betis' way against Osasuna, a direct relegation rival, in a game both sides finished with 10 men.
Betis conceded Roberto Torres' header within two minutes, had Jose "Nono" Delgado dismissed with his second yellow card in the 38th, and saw Jordi Figueras score an own goal in the 57th.
And when Osasuna goalkeeper Andres Fernandez gave them a sliver of hope in the 62nd when he was red carded for fouling Ruben Castro in the area, Castro deflated the crowd at Benito Villamarin Stadium by sending his penalty kick off the crossbar.
Jorge Molina pulled one back in the 80th but Osasuna squandered two chances to widen the margin before the final whistle.
The demoralizing loss left Betis winless in its last 12 league matches and seven points from safety at the season's midway mark.
"We took a step backward today," said Betis coach Juan Carlos Garrido. "I won't deny it. It was important to win today, and besides, clearly our first half of the season was very poor. There has to be a radical turnaround in every facet for us to remain in the first division."
Osasuna stayed unbeaten in four rounds and edged five points clear of the drop.
Rayo's win at Getafe still left it in the relegation zone.
Forward Alberto Bueno scored what proved to be the winner in the 29th after Alejandro Galvez was quick to cross a rebounded shot.
Malaga visits Levante later.