Antoine Griezmann scored twice as Barcelona came from behind to beat Villarreal 2-1 in their La Liga clash at the Estadio de la Ceramica on Sunday.
After Real Madrid dropped points against Real Betis, Barca knew they could move level with their Clasico rivals in second place with a game in hand should they pick up all three points.
Villarreal took the lead through Samuel Chukwueze's composed finish before Griezmann equalised moments later with a quality finish.
The France forward then pounced on a poor back pass by Juan Foyth, on loan from Tottenham, to put Barca ahead.
Villarreal's Manu Trigueros was sent off for a foul on Lionel Messi.
The result put Barcelona two points behind leaders Atletico Madrid, who are away to Athletic Bilbao in the late game on Sunday (20:00 BST).
Ronald Koeman's side, who were 12 points off the top earlier in the season, have one game in hand on Real Madrid.
One of Barca's remaining six league games is at home to Atletico on 8 May.