Match ends, Real Madrid 3, Barcelona 4.
Barcelona breathed new life into their La Liga title hopes as a Lionel Messi hat-trick helped fire them to victory in a thrilling match at 10-man Real Madrid.
Andres Iniesta shot into the top corner before Karim Benzema's brace put Real ahead.
Messi restored parity soon after but Cristiano Ronaldo restored Real's lead from the penalty spot.
After Sergio Ramos was sent off, Messi won the game with two penalties.
It was Messi's second hat-trick in a row as he became the second highest scorer in La Liga history, moving ahead of former Real striker Hugo Sanchez onto 236 goals.
The Argentine also became the all-time top scorer in Clasicos with 21 goals, surpassing Real legend Alfredo Di Stefano, as Barcelona moved to within one point of Sunday's opponents.
Messi has produced some indifferent performances this year but he has been back to his best lately with an inspirational performance in Barca's Champions League passage past Manchester City followed by successive league trebles.
Atletico Madrid's 2-0 win at Real Betis earlier on Sunday means they top La Liga, level on points with city rivals Real but ahead on their head-to-head record this season, but Barca are now within a point of both.
The defending champions travelled to the Bernabeu having lost two of their last four league matches, while Real had not been defeated in their last 31 matches in all competitions.
But Barcelona signalled their early intent through a brilliant early strike into the top corner by Iniesta, after Messi's precise through ball.
Real, who had won their last 17 matches in a row at the Bernabeu, were soon ahead as Benzema made up for an early miss with a quick-fire double.
First he headed home Angel Di Maria's cross and then, four minutes later, the pair combined again as the Frenchman controlled on his thigh before slotting the ball into the net.
For a match that meant so much to both sides, it was surprisingly open and Barca had Gerard Pique to thank for not going further behind as he cleared Benzema's effort off the line.
Neither side looked sure defensively and, just before the break, Messi cut inside the area to fire the visitors level to cap a thrilling half of football.
Real were ahead again in controversial circumstances soon after the restart, as Ronaldo scored from the penalty spot despite being tripped by Dani Alves just outside the penalty area.
The match swung again though when Ramos was shown a straight red card for fouling Neymar, allowing Messi to equalise from the penalty spot.
Alves then hit the post as Real looked content to hold out for the draw before Messi won the game, again from the spot, after Iniesta was sandwiched by Xabi Alonso and Dani Carvajal.
Barcelona have won six of their last 11 league fixtures at the Bernabeu and, also through to the quarter-finals of the Champions League, they will believe they can go on to defend their La Liga title.
Line-ups
Real Madrid
Formation 4-3-3
- 25López
- 15Carvajal
- 12Marcelo
- 14AlonsoBooked at 85mins
- 3PepeBooked at 43mins
- 4RamosBooked at 63mins
- 19ModricBooked at 88minsSubstituted forMorataat 90'minutes
- 22Di MaríaBooked at 35minsSubstituted forIscoat 85'minutes
- 9BenzemaSubstituted forVaraneat 66'minutes
- 11Bale
- 7Cristiano RonaldoBooked at 85mins
Substitutes
- 1Casillas
- 2Varane
- 5da Silva Coentrão
- 18Nacho
- 21Morata
- 23Isco
- 24Illarramendi
Barcelona
Formation 4-3-3
- 1Valdés
- 22Alves da Silva
- 18Alba
- 16BusquetsBooked at 66mins
- 14Mascherano
- 3Piqué
- 6Hernández
- 4FábregasBooked at 43minsSubstituted forSánchezat 78'minutes
- 10Messi
- 11NeymarSubstituted forPedroat 69'minutes
- 8Iniesta
Substitutes
- 7Pedro
- 9Sánchez
- 13Pinto Colorado
- 15Bartra
- 17Song
- 21Correia
- 24Roberto Carnicer
- Referee:
- Alberto Undiano Mallenco
- Attendance:
- 85,454
Match Stats
- Possession
- Home32%
- Away68%
- Shots
- Home13
- Away18
- Shots on Target
- Home8
- Away6
- Corners
- Home1
- Away5
- Fouls
- Home24
- Away12
Live Text
Post update
Full Time
Second Half ends, Real Madrid 3, Barcelona 4.
Post update
Lionel Messi (Barcelona) wins a free kick in the defensive half.
Post update
Foul by Álvaro Morata (Real Madrid).
Post update
Offside, Barcelona. Alexis Sánchez tries a through ball, but Dani Alves is caught offside.
Post update
Attempt missed. Alexis Sánchez (Barcelona) right footed shot from the centre of the box misses to the left. Assisted by Lionel Messi.
Post update
Sergio Busquets (Barcelona) wins a free kick in the defensive half.
Post update
Foul by Gareth Bale (Real Madrid).
Post update
Xavi (Barcelona) wins a free kick on the left wing.
Post update
Foul by Xabi Alonso (Real Madrid).
Substitution
Substitution, Real Madrid. Álvaro Morata replaces Luka Modric.
Post update
Foul by Pedro (Barcelona).
Post update
Daniel Carvajal (Real Madrid) wins a free kick on the right wing.
Booking
Luka Modric (Real Madrid) is shown the yellow card for a bad foul.
Post update
Lionel Messi (Barcelona) wins a free kick in the attacking half.
Post update
Foul by Luka Modric (Real Madrid).
Post update
Andrés Iniesta (Barcelona) wins a free kick in the defensive half.
Post update
Foul by Isco (Real Madrid).
Post update
Offside, Barcelona. Dani Alves tries a through ball, but Alexis Sánchez is caught offside.
Booking
Cristiano Ronaldo (Real Madrid) is shown the yellow card for a bad foul.