ST. LOUIS — One bad inning kept Jimmy Nelson winless in his career against the St. Louis Cardinals.

Nelson (7-14) allowed five hits in six innings and retired the Cardinals in order four times Friday night but he gave up two two-run homers in the third that made the difference in the Milwaukee Brewers’ 4-3 loss.

Nelson fell to 0-7 in eight career starts against St. Louis.

“It’s just a crazy game and stuff happens,” Nelson said. “There’s never really just one answer in this game to anything. You don’t want to think there’s something wrong and start over-analyzing stuff so you just try to keep it simple.”

“No,” Brewers manager Craig Counsell answered pointedly when asked if Nelson’s woes against St. Louis are weighing on the 27-year-old right-hander.

Milwaukee led 3-0 and Nelson had retired the first eight batters when Cardinals starter Carlos Martinez started a two-out rally with a single up the middle. Matt Carpenter followed with his 19th home run, Kolten Wong walked and Stephen Piscotty gave St. Louis the lead and completed the night’s scoring by hitting his 21st homer into the bullpen in right field.

“The two guys that can really hurt him, hurt him,” Counsell said. “He fell behind Carpenter 3-0, which is trouble. Make mistakes to those guys and that’s what’s going to happen.”

Scooter Gennett hit a two-run homer, his 11th, to give the Brewers a 3-0 lead in the top of the third. 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.

The Brewers collected nine hits and had two batters hit in seven innings against Martinez (14-7) but they hit into three double plays. Martinez improved to 3-0 in four starts against the Brewers this season.

“We got a lot of hits but we weren’t in a lot of situations to really score some runs,” Gennett said. “We got three runs on him early but weren’t able to make anything happen later.”

The Brewers lost for only the second time in their past nine games and had a five-game road winning streak end.

“We’ve been playing some good ball as of late,” Gennett said a night after the Brewers opened the series with a 12-5 rout. “Maybe we take three out of four.”

The win improved the Cardinals, the majors’ only winning team with a losing record at home, to 31-38 at Busch Stadium and kept them a half-game behind the New York Mets in the NL wild-card race.

Seung-Hwan Oh worked around a leadoff walk in the ninth for his 17th save in 20 chances. Pinch-hitter Ryan Braun grounded into a force at second for the final out.

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. “That’s one of the best plays we’ve seen here,” Cardinals manager Mike Matheny said. The Brewers popped out into a double play in the fourth.

TRAINER’S ROOM

Cardinals: SS Aledmys Diaz (right thumb) went 2 for 4 for Double-A Springfield in a rehab start Friday night. … 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.