The Brazil winger -- signed from Leeds this month -- put Barca ahead in the 27th minute of the Soccer Champions Tour friendly, firing into the top corner after Eder Militao gave the ball away.
- Preseason schedule: When, where, who Europe's top clubs will play
- Soccer on ESPN+: FC Daily | Futbol Americas
- Don't have ESPN? Get instant access
Madrid were without Karim Benzema -- who only joined preseason training this week -- so Eden Hazard started in attack, while there were also starting spots for new arrivals Antonio Rudiger and Aurelien Tchouameni.
"Benzema is the best player in the world," head coach Carlo Ancelotti told Real Madrid TV after the match. "Of course when he isn't there we miss something."
Lewandowski got a first sight of goal in the 11th minute when his fierce effort was saved by Courtois at the near post.
Rudiger -- who began the match at left-back, with David Alaba playing in central defence -- got forward after 26 minutes, cutting inside and shooting across goal, before Raphinha opened the scoring moments later at the other end.
Militao, harried by Barca's high press, attempted a risky pass across the penalty area, and the winger took advantage, taking a touch before shooting left-footed past Courtois for his second goal of preseason.
Barca coach Xavi Hernandez made five changes at the break -- introducing Pierre-Emerick Aubameyang for Lewandowski -- while counterpart Carlo Ancelotti brought on six new players including a new-look midfield of Casemiro, Luka Modric and Toni Kroos.
Asensio spurned an excellent opportunity to level in the 58th minute, shooting off target after exchanging passes with Lucas Vazquez.
Another substitute, Franck Kessie, was denied by Courtois and Barcelona were unfortunate not to be awarded a penalty after Alvaro Odriozola handled inside the box.
"In the second half we controlled the ball better," Ancelotti said. "In the first half we defended well, with a low block, but we lacked a bit of quality. We saw that in the second half."