In the meeting between the clubs since the 1963 European Cup, Steven Gerrard's men fell behind inside the first 10 minutes, as Rodrygo gave a strong Madrid line-up an early lead.
In front of a heaving Ibrox crowd, Rangers hit back through Zambia international Fashion Sakala just after halftime, before a second yellow to Nacho Fernandez changed the complexion of the match.
Swiss forward Cedric Itten completed the comeback for Rangers in a statement win on the same weekend fierce Old Firm rival Celtic lost 6-2 to West Ham.
RANGERS: McGregor, Tavernier (c) (Jones, 72), Goldson (Balogun, 85), Helander (Simpson, 45), Barisic (Bassey, 61), Davis (Kelly, 85), Lundstram (Arfield, 45), Wright (Kamara, 45), Hagi (Patterson, 61), Kent (Middleton, 61) Sakala (Itten, 61).
REAL MADRID CF: Lunin, Nacho, Marcelo, Vazquez (Marvin, 61), Jovic (Arribas, 45), Odriozola, Odegaard (Morante, 61), Isco, Rodrygo, Chust (Gila, 64), Blanco.