ST. LOUIS (AP) Rookie Aledmys Diaz lined a tying, three-run shot off the foul pole in the fifth inning, one of four homers in a span of nine at-bats against Jeff Samardzija, and the St. Louis Cardinals rallied past the San Francisco Giants 7-4 on Saturday night.

Brandon Moss got the long-ball binge started with his 11th leading off the fifth. Stephen Piscotty and Matt Adams hit consecutive homers in a matter of three pitches to open the sixth for a 6-4 cushion.

The rally rescued Michael Wacha, who left trailing 4-0 after five seemingly on track for a seventh consecutive loss. Wacha has allowed 23 earned runs in his last 23 innings.

More from FoxSports

Samardzija (7-4) had given up five homers in 80 innings all season, and just one in his previous five outings. He opened with four routine innings, permitting three singles and no runner past first base.

Tyler Lyons (2-0), Seung Hwan Oh and Kevin Siegrist each worked a hitless inning before Trevor Rosenthal set the side down in order in the ninth for his ninth save in 10 chances.