Cristiano Ronaldo scored a brilliant goal for Madrid in the first leg of the Super Cup against Barcelona but was sent off after a controversial second yellow card.
But Madrid went on to thrash Barcelona 3-1 away from home to take a huge advantage for the second leg on Wednesday.
The Portugal star came off the bench to blast home the third goal of the visitors' 3-1 win at Camp Nou but earned a second yellow card for going to ground in the penalty area two minutes later, having earlier been booked for taking his shirt off in celebration.
Zinedine Zidane's side took the lead early in the second half through an own goal from Gerard Pique but Barca levelled thanks to Lionel Messi's penalty, which was won in controversial fashion by Luis Suarez.
Ronaldo put Madrid back ahead with a spectacular strike but was dismissed within two minutes of that goal and risked further punishment when he pushed the referee in the back before departing the field.
Barca pushed for a second equaliser late on but were undone by Marco Asensio's brilliant strike on the break, meaning they have it all to do at the Santiago Bernabeu next Wednesday in the first Supercopa tie between these sides since 2012.
Barca had the upper hand in the early exchanges, with Suarez testing Keylor Navas from just inside the area and Dani Carvajal was perhaps fortunate to escape being penalised for handball when blocking Gerard Deulofeu's cross.
Neither side looked prepared to commit to the attack in a rather tepid first half and Gareth Bale saw the clearest chance saved by Marc-Andre ter Stegen from inside the penalty area following Isco's jinking run.
Pique – who scored the winner when these teams met in the International Champions Cup last month – had been booked for attempting to punch the ball towards goal following a corner in the first half and it was another moment of ignominy for the centre-back that gave Madrid the lead five minutes after the break.
Marcelo ran onto Isco's pass down the left and sent a low cross into box, and Pique steered the ball into his own net on the slide as he attempted to clear it for a corner.
Barca suddenly looked unsteady at the back and it took a brilliant sliding block from Jordi Alba to prevent Carvajal from making it 2-0 after some brilliant work from Karim Benzema.
Valverde introduced Denis Suarez from the bench and the move almost paid off immediately, the midfielder's corner headed goalwards by Luis Suarez only for Navas to make a fine one-handed save.
Ronaldo, on in place of Benzema, had a shot blocked behind by Pique and the assistant referee's raised flag denied him when he did find the net following Casemiro's throughball.
The 32-year-old took full advantage of his next chance, though, playing a one-two with Isco to set up a counter-attack before cutting inside Pique and firing into the top-right corner from 20 yards.
Ronaldo was booked for removing his shirt and then stunningly dismissed after being adjudged to have gone to ground too easily in the area under pressure from Samuel Umtiti.
But the incident could not prevent Madrid seizing control of the tie, Asensio rifling home an unstoppable third from the edge of the area to get watching president Florentino Perez onto his feet.