Lionel Messi's hat-trick helps Barcelona beat 10-man Real Madrid 4-3 in a thrilling El Clasico at the Bernabeu. Photo: AP
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 put Real back ahead 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, beating 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 now 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 their city rivals but ahead on their head-to-head record this season, but Barca are now within touching distance of the two of them.
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 after 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 successfully defend their La Liga title.