Lionel Messi scored a wonderful volley to give Barcelona a 2-1 win at Malaga and hand the Catalans three points.
Javi Gracia's men have given Barcelona a rough ride during the four times they have met in the last two seasons and they will probably feel they should have taken at least a point from this game.
Munir El Haddadi had given Barca the lead in the second minute but Juanpi netted the hosts a deserved equaliser eight minutes before the break, only for Messi to restore Barca's lead early in the second half and temporarily take them top of the Primera Division.
Barca lead Atletico Madrid by a point and although Diego Simeone's side can retake top spot on Sunday with a win over Sevilla, the Catalans can reassert their place in the title race when they host Atleti next Saturday.
Luis Enrique made a number of changes from the team that beat Athletic Bilbao 2-1 in the Copa del Rey on Wednesday, bringing in Aleix Vidal, Thomas Vermaelen, Adriano, Messi and Luis Suarez, while Neymar missed out with a hamstring injury.
Malaga took four points from Barca last season and only lost 1-0 at the Nou Camp earlier this term, but the visitors got off to a dream start.
Suarez latched onto a through ball on the right of the area and freed himself of Marcos Angeleri to close in on goal, trying to shoot under Carlos Kameni. The goalkeeper got his body to the ball but could only send it trickling along the goal-line, and Munir arrived to touch it in, scoring his first league goal since 2014.
Malaga coped remarkably well with conceding first and stuck with their plan to press Barcelona high up the pitch and attack them on either flank.
They had a couple of half chances before Chory Castro struck the woodwork, firing a loose ball at goal on the edge of the area, and Claudio Bravo managed to tip it onto the post.
They were then denied a penalty when Charles went over in the box after a challenge from Javier Mascherano, but referee Carlos Clos Gomez made the correct decision in handing the Brazilian a yellow card for diving.
But still Malaga could not be discouraged and they soon levelled, their high pressure paying off. Andres Iniesta tried to play the ball out from the right of defence but his pass was intercepted and Malaga played three quick passes to send the ball in the direction of Juanpi, who took his shot quickly to beat Bravo.
Barca could have got back in front just before the break as Munir's shot was parried by Kameni into the path of Messi, but Miguel Torres reacted quickly to get his body in the way of the Argentine's shot.
Messi used intelligence and guile to score the winning goal, swivelling and diving to volley Adriano's cross into the far corner.
Malaga had plenty of time to find an equaliser and came close to getting one.
Duje Cop was unable to get enough power on a rebound to beat Bravo after the goalkeeper had parried Camacho's shot, and later Roberto Rosales scuffed an effort from the edge of the area which was all to easy for the Chilean to gather, and Barca claimed a vital if fortunate victory.