Lionel Messi scored his 500th Barcelona goal to send them top of La Liga with an injury-time winner against 10-man Real Madrid at the Bernabeu.
Barca, whose win put them top because of a better head-to-head record, have five games left, Real have six to play.
Casemiro scored first for the hosts before Messi and Ivan Rakitic put Barcelona in front and Sergio Ramos was shown a red card for a wild lunge.
Substitute James Rodriguez thought he had earned Madrid a point late on.
But Messi, who scored his first with a superb jinking run and finish, fired in from the edge of the area to win it for Barcelona.
Both Messi and Cristiano Ronaldo had earlier missed good opportunities to give their sides the lead, with the Argentina international poking wide of an open goal before the break and the Real Madrid forward slicing over in the second half.
Real – who have a game in hand on Barcelona – also felt they should have had a penalty when Ronaldo was clipped by Samuel Umtiti after only two minutes.