The Pole Robert Lewandowski saved Barcelona when he scored the only goal of the match from the penalty spot at home against sixth-placed Rayo Vallecano.
The three points mean that Barça is the new league leader in La Liga, but only thanks to a better goal difference than arch-rival Real Madrid. The two giant clubs have 51 points with 14 rounds left to play.
Behind them, Atlético Madrid is lurking on 50 points.