Updated

PHOENIX -- Adam Wainwright pitched into the seventh inning, Yadier Molina and Jedd Gyorko each drove in two runs and the St. Louis Cardinals held on to beat the Arizona Diamondbacks 4-3 Wednesday night.

Wainwright (8-5) limited the Diamondbacks to two runs and eight hits over 6 1/3 innings He struck out eight.

Arizona slugger Paul Goldschmidt went 0 for 4, the first time all season he has gone hitless in four at-bats in back-to-back games.

Gyorko's RBI double in the eighth pushed St. Louis' lead to 4-2.

The Diamondbacks nearly tied it against Trevor Rosenthal in the ninth. Brandon Drury led off with a walk and advanced to second on a wild pitch. One out later, Chris Herrmann walked and both runners advanced on pinch-hitter Gregor Blanco's grounder. Drury then scored on Rosenthal's wild pitch, with Herrmann moving up to third.

After a walk to Daniel Descalso, Rosenthal got David Peralta on a grounder to pick up his fourth save.

Zack Godley (3-2) took the loss, allowing three runs and two hits with seven strikeouts in seven innings. The Diamondbacks snapped a four-game winning streak.

Godley's wildness in the fourth inning proved costly. The Cardinals loaded the bases with no outs as Godley walked Matt Carpenter, Tommy Pham singled and Stephen Piscotty was hit by a pitch that the Diamondbacks challenged but lost. Then came a walk to Gyorko to force in a run.

Yadier Molina bounced a single to left field with the bags full to drive in two runs and make it 3-0 before Godley got out of the inning. The hit extended Molina's hitting streak to 14 games.

The Diamondbacks got a run in the bottom of the fourth on back-to-back doubles from Jake Lamb and Chris Owings. Wainwright then struck out the next three batters, and right after a called third strike to Jeff Mathis to end the inning, Mathis was ejected by home plate umpire D.J. Reyburn for arguing.

That brought Diamondbacks manager Torey Lovullo out of the dugout, and he, too, was thrown out. The ejections were the first two for Arizona this season and the first for Lovullo as a manager.

The Diamondbacks pulled within a run in the seventh after Descalso beat out a potential double-play grounder that would have ended the inning. Rey Fuentes scored, but reliever Tyler Lyons got Peralta to pop out.

AHMED TO DL, MARTE UP

The Diamondbacks placed infielder Nick Ahmed on the 10-day disabled list with a broken right hand, but Ahmed is more likely to be out up to eight weeks after a procedure to place three pins in the hand Wednesday, Lovullo said.

Ahmed suffered the injury when he was hit by a pitch from Rosenthal in the eighth inning Tuesday night. The Diamondbacks called up utility player Ketel Marte from Triple- A Reno in time for Wednesday's game.

Marte, acquired in an offseason trade with Seattle, was batting .338 in 70 games for Reno. He flied out in the seventh inning as a pinch hitter in his Diamondbacks debut.

TAURASI TOSS

Phoenix Mercury guard Diana Taurasi, who recently became the WNBA's all-time leading scorer, threw out the ceremonial first pitch.

TRAINER'S ROOM

Diamondbacks OF Yasmany Tomas (groin) went 0 for 2 in his first rehab game Tuesday night, playing five innings in left field with no pain. … OF A.J. Pollock (groin) played six innings in center field and had four at-bats, including a double on his rehab assignment Tuesday.

UP NEXT

Cardinals: RHP Lance Lynn (5-5) faces the Diamondbacks on Thursday. He has not lasted more than 5 2/3 innings in each of his last six starts, but is 3-0 against Arizona in his career.

Diamondbacks: LHP Patrick Corbin (6-7) is 5-2 in nine starts at home this season.