By Gerard Wright
The visitors had made eight substitutions at the break, introducing several of the squad's big names, and once they had settled after conceding the second, Jose Mourinho's men set about avoiding an embarrassing result in front of 89,134 spectators.
Argentine international striker Gonzalo Higuain pulled one back for Real in the 51st minute, latching on to a pass from Cristiano Ronaldo, and the same player equalized ten minutes later with a deft chip.
Real scored the winning goal in the 71st minute when Galaxy substitute goalkeeper Brian Perk could only parry a shot into the path of midfielder Pedro Leon, whose looping shot from the edge of the area took a deflection before finding the net.
Madrid rallied to beat Mexico's Club America by the same score in the opener of their two-match U.S. tour in San Francisco Wednesday and the team's resilience was something that impressed coach Mourinho.
"For this trip, everything was perfect," Mourinho told reporters. "We trained well. We trained hard. The players were together for 24 hours in a perfect environment for them to grow up as a group."
That bonding appeared to have a positive effect on the side's ability to remain competitive, even in friendlies.
"Obviously, I like this mentality of not wanting to lose, of wanting to overcome, a lot," Mourinho added. "For me the second half was fantastic in every aspect."
(Editing by John O'Brien)