The match saw both Jose Mourinho and Cristiano Ronaldo sent-off.
Real had been unbeaten in the previous 25 meetings between the two sides dating back 14 years and Mourinho's men got off to the perfect start when Ronaldo headed in Luka Modric's corner.
However, Diego Costa levelled for Atletico 10 minutes before half-time and Los Rojiblancos rode their luck as Mesut Ozil, Karim Benzema and Ronaldo all hit the post for Real.
Mourinho, expected to be back in charge at Chelsea next season, was then sent from the touchline 13 minutes from the end of normal time before Miranda headed Atletico in front eight minutes into extra time.
There was even more drama to come as Ronaldo was shown a straight red card for reacting angrily to a late challenge from Gabi with six minutes remaining.
"We had two clear chances on goal, we hit the post three times – this is why I think it is unfair," said Mourinho.
But Gabi who was also sent-off, insisted his side were worthy winners.
"This team has worked hard, to be here with the fans," Gabi told TVE.
"We deserve it, this victory is for them, for those people that have waited 14 years to see Atletico beat Madrid."
Real captain Sergio Ramos was left to rue their missed chances throughout the 120 minutes.
"After the first goal we maybe relaxed and they pushed us back," he said.
"We have four or five clear chances and when you don't take them, then you regret it. It is clear that this is the reality and we have to accept it."
?Mourinho, who could well have sat on the Real bench for the last time as he is now likely to receive a four-game touchline ban, continued to controversially freeze out Pepe after his outspoken comments against the coach.
Raul Albiol was preferred alongside Ramos in central defence.
However, buoyed by the confidence that they had won all eight derbies during Mourinho's reign, Real took just 13 minutes to make the breakthrough as Ronaldo was given far too much room by Diego Godin and Radamel Falcao to register his 55th goal of the season with a precise header.
Gabi responded for Atletico with their first shot on goal moments later that flew over the bar, but despite enjoying a decent spell of possession, Diego Simeone's men were finding it difficult to create a clear-cut opening.
However, when it did arrive on 35 minutes they took full advantage. Falcao called Mourinho's decision to field Albiol into question as he turned the Spanish international and released Costa to fire in his eighth goal in the competition with a low drive past Diego Lopez.
The equaliser sparked Real into life in the final throws of the opening half as Modric drilled a low shot just wide from the edge of the area before Ozil struck the inside of the post with a half-volley.
Real ought to have been back in front on the hour mark as Ronaldo burst down the left and his cut back was fired against the post by Benzema.
Real then struck the post for the third time as a Ronaldo free-kick came back off the upright.
Mourinho was then sent from the touchline for protesting after a number of marginal decisions went against his side.
Atletico had the first chance in extra-time as Costa was released clean through on goal, but his effort was too close to Lopez.
From the resulting corner they did take their chance as Koke's second attempt at a cross from the right was flicked in at the near post by Miranda.
Atletico's task in the final minutes was made easier when Ronaldo kicked out at Gabi and saw a straight red card.
Gabi was also sent off but Simeone's team held on to seal their third trophy in little over a year. – Sapa-AFP