Real Madrid dominated the first half, while the Union had the better of the second half, especially the last 20 minutes.
"I think we pushed the game in the last 20 minutes, and the second half was pretty good," Union team manager Peter Nowak said. "The first half wasn't that good and we made the field too small for us."
Real Madrid led, 2-0, at halftime, frequently putting together sequences where players connected on 10 or more passes, alternating between short touches and long crosses.
Just as in their MLS season, where they have failed to cash in on numerous scoring opportunities despite an 8-4-7 record, the Union didn't take advantage of several Saturday night.
"We had chances in both halves," Nowak said.
Real Madrid's regular season doesn't begin until next month, but the team has taken the World Football Challenge seriously, beating the Los Angeles Galaxy and Chivas Guadalajara by a combined 7-1 score in the first two of the three games it will play in the U.S.
MLS all-star Faryd Mondragon, who got the night off in Wednesday's 1-0 win over Everton in another friendly, was back in goal for the Union, who basically went with their regulars to start the game.
Mondragon, who made a key diving save in the first half, was replaced in the 65th minute by Zac MacMath.
Forward Danny Mwanga, who has started nine games for the Union and is among their best offensive players, didn't start but replaced Carlos Ruiz to begin the second half.
It didn't take Real Madrid long to show its offensive prowess. Jose Maria Callejon one-timed a long pass to open the scoring in the second minute.
In the 11th minute Real Madrid made it 2-0 on the old give-and-go, with Karim Benzema feeding German national team standout Mesut Ozil, who connected from inside the box.
In the 13th minute Union defender Danny Califf was wide on a header from a Sebastien Le Toux corner. Real Madrid keeper Iker Casillas made a kick save from close range on Le Toux in the 19th minute.
Union defender Sheanon Williams had a close shot blocked and cleared by defender Raphael Varane in the 29th minute.
Casillas beat Ruiz to the ball in the 32d minute. Le Toux shot just wide from 12 yards out in the 35th minute.
Real Madrid's top two offensive players, Cristiano Ronaldo and Kaka, played the entire second half after sitting out the first 45 minutes. Yet the Union applied much more pressure in the second half.
Both Ronaldo and Kaka were among seven new players inserted by Real Madrid to begin the second half. In the 57th minute Ronaldo had his first scoring chance, heading wide a cross from the extremely active Callejon.
In the 63d minute, Ronaldo sent a 25-yard blast just past the near post.
Every time Ronaldo touched the ball, the crowd would anticipate something spectacular. The white-shirted Real Madrid fans were plentiful, and the team they were rooting for gave them plenty to cheer about.
The Union cut the deficit to 2-1 on a goal by Michael Farfan in the 80th minute. Taking a feed from Danny Mwanga, Farfan chipped the ball from near the 18 over the head of keeper Tomas Mejias.
Mejias preserved the win by making a diving save on a shot by Jack McInerney from near the 18-yard line in stoppage time.
"I didn't think I got enough behind it," McInerney said. "Once I saw it again I realized how close it was."
Just like his team.
Contact staff writer Marc Narducci at 856-779-3225, email@example.com, or @sjnard on Twitter.