|Real players celebrate with Argentinian Ezequiel Garay after the third goal [EPA]
Real Madrid edged Valencia 3-2 to stay with Spanish leaders Barcelona, who marked their last domestic game of 2009 with a 1-0 win over cross-town rivals Espanyol.
Ezequiel Garay headed Xabi Alonso's long free kick sharply into goal in the 83rd minute for Madrid's winner that came only three minutes after Joaquin Sanchez equalised for Valencia for the second time.
Gonzalo Higuain scored twice while David Villa struck his league-leading 12th goal to cancel out the Argentina striker's 54th-minute opener.
Madrid stayed within five points of Barcelona, who couldn't have asked for a better sending off for their Club World Cup date against Mexico's Atlante on Wednesday as the European champions go for their sixth major trophy since May on the heels of a sixth straight victory.
Zlatan Ibrahimovic made no mistake in beating goalkeeper Carlos Karmeni with a 39th-minute penalty shot into the top corner after Xavi Hernandez was fouled.
Ibrahimovic's 11th league goal sent Espanyol crashing to their fourth straight defeat in the 151st meeting between the teams.
"We should really value this victory because it comes from a derby and because we're tired from playing so many games,'' Barcelona coach Pep Guardiola said.
Barcelona lead with 39 points, although they have played one game more than Madrid, who have 34 points. Valencia stayed third with 28, Sevilla have 27 and Deportivo La Coruna 25.
Earlier, Mikel San Jose and Markel Susaeta scored second-half goals to lead Athletic Bilbao to a 2-1 win at Zaragoza, a defeat which reportedly cost coach Marcelino Garcia his job.
Spanish media reported that Marcelino became the second Spanish league coach fired this season after Atletico Madrid's Abel Resino.
Carlos Diogo scored for Zaragoza, who have lost three straight, in injury-time.
Athletic have 23 points and Zaragoza are 17th with 12 points, one back of Espanyol.
In a match featuring countless opportunities from the opening moments, it was Madrid that got ahead first at the Mestalla after Valencia had good chances by Pablo Hernandez and Juanma Mata turned away.
Higuain, who missed a first-half try, was unmarked to receive Karim Benzema's short cross from the left to open.
But Madrid's joy was short-lived as Villa got up to head Jeremy Mathieu's precise cross into the empty goal five minutes later as goalkeeper Iker Casillas wrongly came out.
Higuain netted his eighth of the season in the 65th with an angled shot before substitute Joaquin evened it when Casillas was too slow to react to a hard shot that glanced off the Spain goalkeeper and into goal.
But Garay, who replaced the injured Pepe in the 45th, managed to glance in Alonso's long cross for the winner.
"The most important thing was to come here and play a good game,'' said Higuain in reference to absent stars Cristiano Ronaldo and Kaka.
"We're better, we're playing like we want to.''
Lionel Messi watched from the Camp Nou sidelines with an ankle injury, but took to the field to display his Golden Ball award to the near 85,000 fans before kickoff.
Barcelona broke through after the 38th, when Xavi dropped inside the area after slight contact with Jose Baena as the two duelled for a cross.
Ibrahimovic, whose quick touches and slick passes troubled Espanyol's defence throughout, tested Kameni again in the 49th before Espanyol finally began to create occasions, with Javier Marquez and Ivan Alonso getting the visitors' best by the 63rd.