A Lionel Messi hat-trick put Barcelona firmly back in the La Liga title race on a night of high drama at the Bernabeu.
The Argentine notched two penalties late on after Sergio Ramos had been handed a red card for a foul on Neymar when clean through.
Madrid appeared to be in the ascendency for much of El Clasico on Sunday and twice took leads.