United edged out Zinedine Zidane's European champions on penalties in Santa Clara after Casemiro cancelled out Jesse Lingard's exquisite opener.
The Reds - who will lock horns with the Spanish giants again in the UEFA Super Cup on 8 August - were involved in one of the comically awful shoot-outs ever witnessed.
Only three of the ten spot-kicks found the target, with Henrikh Mkhitaryan, Daley Blind and Real's Miguel Quezada the only players to be successful from 12 yards.
Martial, Mateo Kovacic, Scott McTominay and Oscar missed the opening four penalties, before Mkhitaryan and Quezada both scored.
Lindelof and Real's new signing Theo Hernandez then also both failed to covert, but Blind made it 2-1 and Casemiro struck the bar with the final effort to conclude a 2-1 success for the Reds.
Lingard called Keylor Navas into action with an early effort from distance, and went close again with a 25-yard yarder that drifted narrowly wide shortly afterwards.
The Academy graduate was United's most impressive performer, and he capped a superb individual showing with a deserved goal on the stroke of half time.
It was a strike indebted to a breathtaking solo run by Martial, who slalomed beyond five Real players and cut the ball back for the lurking Lingard who applied the finish.
Marcelo had an instant reply ruled out for offside before the usual raft of half-time changes by both bosses to give all squad members a handy run-out.
Jose made eight substitutions at the interval and was forced to make a ninth six minutes later when Ander Herrera struggled off clutching his ribs, replaced by young Academy player McTominay.
Debutant Hernandez went down under a mistimed challenge from Lindelof and Casemiro stepped up to slam home the spot-kick beyond David de Gea.
Eight minutes later, play was halted for a second time for a water break to keep both sets of players hydrated in the searing Californian heat.
Marouane Fellaini fired wide late on when well placed, before - despite only being a pre-season fixture - penalties would be needed to determine the winner.
United: Romero (De Gea 46); Fosu - Mensah (Blind 46), Bailly (Lindelof 46), Jones (Smalling 46), Darmian (Valencia 78); Carrick (Herrera 46) (McTominay 51), Fellaini; Pereira (Pogba 46), Lingard (Mkhitaryan 46), Martial; Rashford (Lukaku 46).
Real Madrid: Keylor Navas; Carvajal (Hakimi 46), Varane (Quezada 46), Nacho (Manu 46), Marcelo; Modric (Kovacic 46), Kroos, Isco (Oscar 46); Lucas Vazquez (T Hernandez 46), Benzema (Gomez 46), Bale (Franchu 46).