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.

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.