Swiss striker Cedric Itten netted a stylish winner with less than 15 minutes remaining at Ibrox after Los Blancos defender Nacho had been dismissed for a second bookable offence.
Rangers had trailed at half-time courtesy of a counter-attacking Real Madrid goal finished off by Brazil’s Rodrygo, with Ryan Kent hitting the crossbar and the likes of John Lundstram, Connor Goldson and Fashion Sakala all going close during an impressive opening 45 minutes.
Zambian international Sakala - who signed a four-year deal in Glasgow in May after leaving Belgian side KV Oostende - did level the scores 10 minutes after the interval.
It was another very satisfying pre-season outing for Steven Gerrard’s side, who won their 55th Scottish top-flight title in May - a first since 2011.
Rangers also led twice against Arsenal in Glasgow last weekend as 2,000 fans returned to Ibrox, with Leon Balogun and Itten both scoring in a lively 2-2 draw.
A Rangers side also drew 0-0 with Brighton on Saturday, while they previously beat Partick Thistle and lost to Tranmere Rovers in earlier summer friendlies.
The Light Blues open their Scottish Premiership title defence with the visit of Livingston to Ibrox next Saturday (July 31).