Lionel Messi scored his 40th goal of the Primera Liga campaign as Barcelona beat basement boys Deportivo while Atletico Madrid’s hundred per cent home record was ended, allowing Real Madrid  to usurp them in second place.

A below-strength Barca bounced back from successive Clasico defeats with a routine win over the Galician strugglers at Camp Nou, but only a first half Alexis Sanchez header separated the teams until the final minutes when Messi, on as a substitute for David Villa, sealed the win.

With reserve keeper Pinto between the sticks, Barca managed their first clean sheet in 14 games, the suspended Victor Valdes having been red-carded at the end of El Clasico a week previously.

Real Madrid overtook neighbours Atletico, but remain 13 points behind Barca after a 2-1 win at Celta Vigo. Cristiano Ronaldo put Los Blancos in front after the break, before Iago Aspas equalised almost immediately. Jose Mourinho’s men struggled to make their superiority count, but Ronaldo’s 72nd-minute spot-kick made the difference as Celta fell to nineteenth place.

Atletico slipped to a 1-0 loss to Real Sociedad, dropping their first points of the season at the Vicente Calderon. Xabier Prieto’s 53rd minute strike took Sociedad to fifth, level on points with Malaga, who were held to a 1-1 draw at Real Valladolid. Former Bayern Munich defender Martin Demichelis headed in to give Manuel Pellegrini’s side an early lead, only for Manucho to level before the interval.

Real Betis are sixth after beating Osasuna 2-1 on a sodden pitch at the Benito Villamarin. Jorge Molina gave Pepe Mel’s men an early lead, which they held until sixteen minutes from time, when Francisco Silva equalised, only for Ruben Castro to grab the points for Betis five minutes later. Valencia missed the chance to go above both Malaga and Sociedad, slipping to seventh with a 1-0 defeat at Athletic Bilbao, Iker Muniain getting the vital goal eleven minutes from the end.

Levante and Getafe played out a 0-0 draw at the Ciutat de Valencia to leave both sides in mid-table. A similar scoreline between Zaragoza and Granada left both clubs hovering too close to the danger zone for comfort.

Chori Dominguez and Piti, with his 11th goal of the season, were on target as Rayo Vallecano maintained hopes of a Europa League spot with a 2-0 at home against Espanyol, while at the bottom an Alejandro Alfonso double helped Mallorca overcome Sevilla 2-1. Alfredo Negredo scored for inconsistent Sevilla but the islanders’ win, their first at home since September, could be vital in their quest to avoid relegation.