Barcelona needed some Lionel Messi magic to see off Malaga at the Rosaleda on Saturday as the Argentine guided the Catalans to a 2-1 victory.
Luis Enrique's side made a superb start to the game as Munir El Haddadi found the net after just two minutes of play following some good work from Luis Suarez.
Malaga did well to keep the reigning champions at bay from there on, however, and deservedly levelled the score via Juan Pablo Anor in the 32nd minute.
Messi eventually secured the full three points for Barca after all, though, netting an acrobatic volley that left Carlos Idriss Kameni with no chance.
Elsewhere, fourth-placed Villarreal had to settle for a 2-2 draw away against Espanyol.
Felipe Caicedo gifted the Catalans an early lead after being set up by Papa Kouly Diop, but Manuel Trigueros restored parity halfway through the first half.
Gerard Moreno's goal shortly before the break appeared to be enough for the full three points for Espanyol, yet Mateo Musacchio salvaged a draw for the Vila-Real side late on.
The home side were reduced to 10 players immediately after as Moreno received his second booking of the game.
Granada recorded a 3-2 win over Getafe in an entertaining encounter at the Nuevo Los Carmenes.
Fran Rico and Youssef El Arabi gifted Granada a two-goal lead before the break, but Stefan Scepovic and Moi Gomez helped get Getafe back in it.
Nevertheless, Ruben Rochina's second-half goal ensured the full three points for Jose Ramon Sandoval's men.
Rayo Vallecano beat Celta Vigo 3-0 to move out of the relegation zone for now.
Strikes from Miku, Tito and Jozabed Sanchez saw Rayo go three goals clear in the opening 45 minutes and the visitors were unable to respond in the remainder of the game.