ST. LOUIS — Matt Carpenter and Stephen Piscotty hit two-run homers in the fourth, Carlos Martinez pitched seven solid innings and the St. Louis Cardinals beat the Milwaukee Brewers 4-3 on Friday night.

St. Louis trailed 3-0 when Martinez started the winning rally with a two-out single that was followed by Carpenter’s 19th home run, a walk to Kolten Wong and Piscotty’s 21st homer.

Martinez (14-7) gave up nine hits and two earned runs and was helped by three double plays. He improved to 3-0 in four starts against Milwaukee.

Jimmy Nelson (7-14) allowed both homers and five hits in six innings and fell to 0-7 in eight career starts against St. Louis.

Seung-Hwan Oh worked around a leadoff walk in the ninth for his 17th save in 20 chances.

Scooter Gennett’s two-run homer in the third gave the Brewers a 3-0 lead. Milwaukee scored an unearned run in the first when Gennett walked, Chris Carter was hit by a pitch and Kirk Nieuwenhuis hit a hard one-hopper that shortstop Jedd Gyorko did not handle.

DOUBLING UP

Martinez induced double-play grounders in the second and third innings to increase his NL-leading total to 32, two shy of the Cardinals’ team record set by John Denny in 1978. Wong backhanded a grounder up the middle and scooped the ball from his glove to Gyorko to start the third-inning double play. The Brewers popped out into a double play in the fourth.

TRAINER’S ROOM

Cardinals: RHP Trevor Rosenthal (shoulder inflammation) will throw to hitters Saturday for the first time since he went on the DL on July 26.

UP NEXT

Brewers: RHP Chase Anderson (8-11, 4.73) has allowed three earned runs in 10 1/3 innings in two starts at Busch Stadium this season.

Cardinals: RHP Adam Wainwright (10-8, 4.61) has allowed one home run at home this season but has lost his past two home starts.