Joey Votto and Donovan Solano each had a solo homer for the Reds, who hadn't scored more than three runs since an 8-2 win July 30 over Baltimore.
Milwaukee fell a game behind the St. Louis Cardinals, who blanked the New York Yankees 1-0 for their sixth consecutive victory.
With the Reds leading 2-0 in the fourth inning, Barrero launched a two-run homer into the Brewers' bullpen off starter Aaron Ashby (2-10).
The third-year shortstop added a solo shot into the same bullpen in the sixth off reliever Hoby Milner, extending Cincinnati's lead to 5-3.
''When you're right and you feel comfortable, it really doesn't matter who the pitcher is sometimes, and I felt like he was that locked in tonight,'' Reds manager David Bell said.
The homers came in the 125th and 126th at-bats of Barrero's career. They were the first two hits this season for Barrero, who was recalled from Triple-A Louisville on Wednesday.
''It's incredible. To have this come up today just feels amazing,'' Barrero said through a translator.
Barrero, a Havana native, said he dedicated the home runs to his late mother, Tonia Barrero, who died in Cuba from symptoms related to COVID-19. He changed his name last year from Jose Garcia to honor her.
Milwaukee scored twice off reliever Hunter Strickland in the ninth to make it 7-5, but squandered two good chances when the game was closer.
Trailing 4-3 in the fifth, the Brewers loaded the bases with one out against rookie starter Nick Lodolo. The left-hander struck out Mike Brosseau before righty Buck Farmer (1-1) retired Hunter Renfroe to end the inning.
Down 5-3 in the sixth, Milwaukee had two runners on with two outs when right fielder Aristides Aquino threw out Victor Caratini at the plate on Christian Yelich's single.
Andrew McCutchen hit a solo homer and Keston Hiura had a two-run shot for Milwaukee in the fourth.
McCutchen also had a sacrifice fly in the ninth.
Reds: Rookie RHP Hunter Greene (right shoulder strain) had an MRI but won't need surgery, Bell said.
Brewers: RHP Adrian Houser (right flexor strain), on the 15-day injured list since July 1, began a rehab assignment with Triple-A Nashville.
Prince Fielder joined the Brewers Walk of Fame, and Ryan Braun and Jonathan Lucroy joined the club's Wall of Honor.
Bell played for the Brewers late in 2006, his final season in the majors and Fielder's second.
''He was like a leader of the team already. He just had that personality,'' Bell said. ''He had like all the wisdom and experience, everything that you would expect in a much older player.''
Bell's father, Buddy, managed Fielder's father, Cecil, on the 1996 Tigers.
Barrero became the second batter in Reds history to hit his first two major league home runs in the same game. The first was Harry Steinfeldt on July 31, 1900, at Boston, according to the Elias Sports Bureau. ... Fourteen rookies, including nine pitchers, have appeared in at least one game for the Reds this season. Six times, most recently July 31 to Aug. 2, the Reds started rookie pitchers in three straight games.
Rookie RHP Graham Ashcraft (5-2, 4.12 ERA) faces Brewers RHP Corbin Burnes (8-5, 2.49) on Sunday to complete the three-game series. Ashcraft did not permit an earned run over 8 1/3 innings in his last start, a win at Miami. Burnes, an All-Star and the reigning NL Cy Young Award winner, gave up four runs and walked five over 5 1/3 innings in his last start, a loss at Pittsburgh.
More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.