Lionel Messi scored his 500th Barcelona goal to send the Catalans top of La Liga with a last-minute winner against 10-man Real Madrid at the Bernabeu.
It puts Barcelona level on points with Real Madrid, but with a better goal difference and head-to-head record.
Casemiro had put the hosts ahead before Messi and Ivan Rakitic goals put Barcelona in front and Sergio Ramos was shown a red card.
Substitute James Rodriguez thought he had earned Madrid a point late on.
But Messi fired in from the edge of the area to win it for Barcelona.