Alexis Sanchez and Ander Herrera put United into a two-goal lead in Tuesday's friendly in Miami, and although Karim Benzema halved the deficit before the break, the Premier League club held on for a morale-boosting victory.
Benzema responded for Real, but in the 18th minute United went in front when Sanchez converted from close range after getting on the end of a cross from Matteo Darmian.
The English side doubled their advantage before the half-hour mark in some style, with Sanchez heading Mata's cross into the path of Herrera who finished with a first-time effort.
Real had been second best in Florida, but the European champions pulled a goal back just before the break through Benzema, who finished from close range after meeting an outstanding delivery from the left from Theo Hernandez.
Julen Lopetegui make a number of changes after the break - with Mourinho opting to keep the same XI - and it almost worked in the Spanish side's favour, only for Martin Odegaard to send a good chance over the bar.
However, United managed to hold on for the win ahead of travelling to Germany to face Bayern Munich at the weekend.
MANCHESTER UNITED (4-3-3) De Gea; Darmian, Bailly, Fosu-Mensah, Shaw; Fred (Tuanzebe 68'), Herrera, McTominay (Mitchell 79'); Pereira, Mata (Garner 83'), Sanchez
REAL MADRID (4-2-3-1) Casilla (Lunin 46'); Odriozola (Galache 62'), Vallejo (Nacho 77'), Sanchez, Hernandez (Rodriguez 46'); Llorente (Asensio 77'), Valverde (Isco 77'); Vinicius (Arnaiz 62'), Ceballos (De Tomas 62'), Bale (Odegaard 46', Kroos 77'); Benzema (Mayoral 46')