Inter, who entered the contest one point better off than their opponents, battled back through well-taken strikes from Lautaro Martinez and Ivan Perisic either side of half-time.
But Madrid regained their lead late on when substitutes Vinicius Junior and Rodrygo combined on the counter, making it five games without a win for Inter and under-pressure boss Antonio Conte.
Marco Asensio was denied by a smart Samir Handanovic save and Nicolo Barella scraped the top of the crossbar with a header in a lively and end-to-end start to the showdown.
That set the tone for what was to follow as Benzema pounced on Hakimi's underhit backpass, rounded Inter goalkeeper Handanovic and tucked the ball into an empty net for the 25th-minute opener.
Ramos added a second for Madrid eight minutes later by getting away from his marker to meet Toni Kroos' corner and head in from the edge of the six-yard box.
Inter gave themselves an instant lifeline as Barella superbly flicked the ball into the path of Martinez to pick out the bottom-left corner 10 minutes before the interval.
Conte's Inter, once again without injured striker Romelu Lukaku, initially struggled to get at their opponents in a quieter second half in the Spanish capital.
However, against the run of play, Martinez nodded the ball into the path of Perisic and the makeshift striker held off Lucas Vazquez before rifling across Thibaut Courtois.
Both teams went in search of a winner and it was Madrid who found it – Vinicius leading a break down the left and feeding the ball to fellow Brazilian Rodrygo, who took a touch to set himself and then found the top-right corner to win the match during the closing stages.