Barcelona came from behind to take a slender lead from the first leg of the Spanish Super Cup at the Camp Nou.
Cristiano Ronaldo headed Real into the lead against the run of play ten minutes into the second-half from Mesut Ozil's corner, but Barcelona responded as Pedro showed great poise to slot home a minute later.
The action then raced from end to end and it was the hosts who forged ahead 20 minutes from time when Lionel Messi scored from the penalty spot after Sergio Ramos had brought down Andres Iniesta.
Then a terrific jinking run from Iniesta freed Xavi to stroke home Barcelona's third goal seven minutes later. However, the visitors were gifted a way back into the tie five minutes from time when Barcelona goalkeeper Victor Valdes tried to dribble around Angel Di Maria and only succeeded in gifting the Argentinian an open goal.
Barcelona were deserving of the victory, but they may yet rue not taking full advantage after dominating for large spells against a Real side who failed to find the cohesion that had seen them go unbeaten in three of their last four trips to the Nou Camp.
Messi had the first real chance of the game when a typically sharp Barcelona passing exchange freed Dani Alves down the right and his cut-back found the Argentinian on the edge of the penalty area, but his left-footed drive flew just off target.
The FIFA Ballon d'Or winner then had an even better opportunity from similar range as he skipped past Alvaro Arbeloa, but this time he pulled his shot wide of the other upright.
Real were struggling to manage any prolonged possession and were relieved to see referee Carlos Clos Gomez wave away appeals for a penalty when Alexis Sanchez tumbled in the box under pressure from Ramos. However, for all their dominance, Barcelona only had another two long-range efforts on goal as Pedro's drive was tipped over by Iker Casillas before Xavi shot just over from similar range.
And it was the visitors who took the lead ten minutes into the second period as Ozil's corner was bulleted in by Ronaldo for his fourth goal in his last four away games against Barcelona. That lead lasted less than a minute as a wonderful ball over the top from Javier Mascherano found Pedro in behind Fabio Coentrao and the Spanish international slotted past Casillas.
The game then became increasingly stretched as both sides tired slightly from playing in the still searing heat, despite the late night kick-off time, and the visitors' luck with Gomez eventually ran out as Iniesta was brought down inside the area by Ramos and Messi stepped up to thunder home the penalty.
Moments later Iniesta showed incredible speed of foot to dance past three Real challenges and slip a pass through for Xavi to sidefoot past Casillas.
Messi then had a great chance to all but seal the trophy, but he was denied from point-blank range by Casillas, and within seconds the complexion of the tie had completely changed as Valdes' error allowed Di Maria to give Madrid a lifeline heading into the return at the Bernabeu next Wednesday.