Early in the second half, the chant went up: "Mourinho, stay!" The problem for the Real Madrid manager was that it was the Barcelona fans who were singing it. Just as it was the Barça fans who unveiled a mock advert that ran: "Wanted: a worthy rival for a decent clásico. Ask here for details." The Catalans were winning 2-0 but they sang too soon. José Mourinho's side have now won just one of 10 games against Barcelona and were eventually knocked out of the Copa del Rey. But not before giving the Camp Nou a hell of a fright.

No sooner had the song gone round this stadium than Real Madrid scored twice, through Cristiano Ronaldo and Karim Benzema, to make it 2-2 and set up 20 tense and dramatic final minutes. A solitary goal would have put Madrid through – and there were chances too. This was a wonderful game that swung one way, then the other and then back again. Barcelona scored twice in three first-half minutes; Madrid scored twice in four second-half minutes. Both could have scored more in the other 83. This was arguably Madrid's best clásico display under Mourinho.

When the final whistle went, Madrid surrounded the referee. Sergio Ramos had only recently departed, receiving his second yellow, and they felt that there should be more time left on the clock. They exited the Copa del Rey – the trophy that they won last season with that one victory against Barcelona. Yet while Madrid lost their grip on the cup, they may feel that their recent crisis loosened its grip on them. This time, they competed; this time they did what the failed so abjectly to do seven days ago. Barcelona met the final whistle with relief; those ironic chants had been silenced.

Mourinho acknowledged as much. "I heard in the dressing room: 'It's impossible to win here.' At half-time I didn't have to talk much because we were playing so well," he said. "They scored without having done anything to score while we had three, four, or five great chances. I would congratulate Barcelona for the victory at the Bernabéu but not today."

The last seven days have been difficult for Mourinho. Defeat in the first leg was followed by criticism and intrigue. Leaks revealed splits in the squad and began a mole hunt. There was moral opprobrium too. Pepe was singled out for his stamp on Leo Messi in the first leg. Amid suggestions that he should be left out for diplomatic reasons, Mourinho decided otherwise. The Portuguese defender, who learnt before the kick-off that he will not be handed a ban, was included. Outside, wanted posters with Pepe's face on were taped to trees all the way up to the stadium. Inside, the noise was deafening. Every time he touched the ball, it rose a pitch. Chants of "assassin!" rang round. When Messi caught him with a scything challenge just before half time, he rolled and the Camp Nou rocked. "Messi! Messi!"

Madrid were swiftly at Barcelona's throats – in the right way. Pepe had been included but so too had Kaká, Mesut Ozil, Gonzalo Higuaín and Ronaldo. Pressuring high, suffocating Barcelona, Madrid created chances from the very start. They could have been in the lead after just eleven seconds. Gerard Piqué watched a pass go beyond him and back towards José Pinto's goal, unaware that Higuaín was racing in behind him. Barely able to believe the position he found himself in, the Argentinian scuffed his shot well wide. It was an awful miss.

One minute and twenty-nine seconds later, Madrid again should have scored when Xabi Alonso's free kick swung past a static defence towards Sergio Ramos and Higuaín. Again the Argentinian was there. This time Pinto made the save. A pattern had emerged. Barcelona were uncomfortable, the centre-backs slow and caught out of position, surprisingly prone to misjudging the run and the bounce of the ball. Pinto saved again from Cristiano Ronaldo, and Higuaín; Ozil thundered a shot off the bar. Already, Madrid had regained some of the credibility they had lost over the last week. What they had not gained was the lead.

A couple of minutes before half-time Madrid had had five shots on target, Barcelona none. Then, suddenly, they had two – and these two counted. Dani Alves somehow squirmed away from pressure on the right and found Messi. The Argentinian accelerated through the middle and squeezed the ball between Pepe and Ramos to Pedro. Pedro, who had come on for the injured Andrés Iniesta, scored. Two minutes later Alves sent the ball screeching into the far top corner.

When Ronaldo reached Ozil's pass and skipped beside Pinto to score a neat goal, it was no more than Madrid deserved. It might have been considerably less. And then suddenly, Karim Benzema dashed in, brought the ball down and beat Pinto. There were 20 minutes to go and the tie was alive. There were chances at both ends. Ramos even had the ball in the net, only for his goal to be ruled out for a tug on Alves. The final whistle was met with roars of relief. Ultimately the result may have been the same but Barcelona's fans had changed their tune.

This article was amended on 26 January 2012. José Pinto was in goal for Barcelona, not Victor Valdés