Jose Mourinho's depleted side produced an uninspiring performance and struggled for large parts of the game, but they made the most of their chances.
Radamel Falcao gave the hosts an early lead but an own goal by Juanfran levelled things up a few minutes later, and Angel Di Maria hit the winning goal midway through the second half.
The result sees Real cut the gap on leaders Barcelona - held to a 2-2 draw by Athletic Bilbao - to 11 points with five games remaining, while they are now six points clear of Atletico in the battle for second place.
The game kicked off to a raucous atmosphere inside the Calderon. Atletico fans had waited 14 years to beat their neighbours and knew this was their best chance, with Real expected to rest a number of key players before Champions League semi-final second leg Borussia Dortmund next week.
Mourinho did as expected, fielding just three players - Diego Lopez, Sami Khedira and Pepe - that started in Dortmund.
Atleti's only key absentee was Arda Turan and they made the difference in personnel count early on, applying sustained pressure from the start.
They were awarded a free-kick 30 yards out after three minutes. Gabi went for goal and caught out Lopez, who could only palm his shot out to Diego Godin, who put the ball back across goal and Falcao headed home from inside the six-yard box.
Atleti kept up the pressure and Koke fired a shot over the bar from range.
Real had little response but equalised out of nothing on 12 minutes. Di Maria won a free-kick in a similar area to the one Atleti scored from and went for goal, the ball tacking a deflection off Juanfran's hip, which sent it beyond the helpless Thibaut Courtois.
The goal sucked the life out of Atleti. They only created two more chances in the half, Falcao heading well over the bar, and then Diego Costa skewing well wide of goal.
At the other end, Alvaro Morata shot well wide from a difficult angle and Courtois came racing out of goal to deny Karim Benzema, who had been played in by Di Maria.
Atletico came out the far stronger team in the second half and mounted pressure on the Real goal from the off.
Raul Garcia struck the bar just after the re-start, while Gabi squandered a great chance to restore the lead when he burst through the defence but scuffed his shot wide.
A minute later Garcia sent a shot just wide of the far post, before Falcao appealed for a penalty in vain after a challenge by Michael Essien.
Real had barely done anything in the second period up to this point, but when they launched their first attack, they scored.
Benzema found Di Maria in space down the left wing and the Argentinian cut inside before shooting into the bottom far corner, beyond the reach of Courtois.
The home fans were stunned and Atletico had little response. Their only subsequent shot was an effort from Filipe Luis from a tight angle that went just wide, while Benzema and Morata both missed chances for Real.