The Giallorossi icon scored the only goal of the game in the 58th minute, converting a cross from Alessandro Florenzi after releasing his team-mate with a clever dummy
Francesco Totti scored a fine second-half goal at the Cotton Bowl in Texas to see the Serie A side to their first win of the pre-season tournament.
Madrid – beaten on penalties by Inter in their opening game – had their chances, particularly during the first half, but failed to capitalise and were punished by Roma's veteran captain as their hopes of retaining the International Champions Cup were extinguished.
Things threatened to boil over even before kick-off after Roma midfielder Seydou Keita, formerly of Barcelona, refused to shake Pepe's hand and then threw a water bottle at the Madrid defender.
Los Blancos, though, started the better of the two teams, with Gareth Bale proving a real handful for Roma down the left-hand side. Unsurprisingly, the first real chance of the game fell to the Wales international, in the 20th minute.
A fine team move led to a cross from Lucas Vazquez for Bale, but the attacker could only slice his shot well wide under heavy pressure.
Roma looked the more threatening side on the counterattack but Bale continued to cause them problems, shooting over from the edge of the area.
Luka Modric was heavily involved, too, and combined well with Bale on several occasions, but Carlo Ancelotti's men would somehow fail to score in the opening half.
Winger Vazquez forced Lukasz Skorupski into a save after a volley from inside the area and Mehdi Benatia made a brilliant block to deny Pepe on the follow up just before the break.
It would be Roma who took the lead in the 58th minute thanks to Totti. The No.10 dummied a pass that found Alessandro Florenzi's overlapping run down the right before continuing his run into the area and then finding the bottom corner with his team-mate's subsequent cross.
Substitutions ruined the flow of the game, but Roma were largely untroubled in seeing out a game that was repeatedly disrupted by a succession of pitch invasions late on.