Brandon Crawford drove in a pair of runs, Brandon Belt doubled twice and the Giants defeated the Cardinals, 7-5, on Thursday in the finale of a two-game series.
Emmanuel Burriss hit a game-tying sacrifice fly in the sixth inning and San Francisco went ahead for good later in the frame when Belt scored on a throwing error by Cardinals third baseman David Freese.
Matt Cain (3-2) allowed four runs over six innings to record the win for the Giants, who halted a two-game skid and earned a split in the brief series.
"The guys showed more patience," San Francisco manager Bruce Bochy said of his team's approach at the plate. "We swung the bats well."
Matt Holliday had a two-run homer and a sac fly for the Cardinals, losers of five of their last seven games overall.
Adam Wainwright (2-5) was charged with five runs -- two earned -- on six hits and four walks over 5 2/3 innings.
Holliday's homer to left came on the heels of Matt Carpenter's leadoff single and gave the Cardinals a 4-3 lead in the third inning.
The Giants had runners at second and third with no outs in the sixth after a single by Angel Pagan and a double by Belt. Burriss plated the tying run with a sacrifice fly to left field and Wainwright was relieved after retiring Charlie Culberson.
Pinch-hitter Aubrey Huff then hit a grounder to third base off of Victor Marte. Freese, who had an RBI sac fly in the first, fielded the ball cleanly but his throw to first base was short and wide, allowing Belt to score from second.
In the seventh, Belt hit an RBI double and Pagan crossed the plate on Culberson's bases-loaded groundout for a 7-4 lead.
Yadier Molina hit a solo homer for St. Louis in the eighth but Santiago Casilla tossed a 1-2-3 ninth to seal the win for San Francisco win.
Holliday's sac fly also came in the first inning, as the Cardinals grabbed a 2-0 lead, but the Giants got an RBI single from Buster Posey in the bottom half and pushed a pair across in the second.
Posey drove home Crawford, who doubled and advanced to third on an error by Carpenter. An inning later, Burriss reached on an error by first baseman Lance Berkman and Wainwright walked Gregor Blanco before allowing him to advance on a wild pitch. Crawford delivered a two-out, two-run single for a 3-2 lead.
"The first two innings (I had) two outs with guys on third and I didn't get out of it unscathed either time," said Wainwright. "That's something I pride myself on in my career and usually I'm pretty tough in that situation."
Casilla picked up his ninth save of the season...Pagan went 1-for2 and has hit safely in 28 of his last 29 games...Wainwright fell to 1-4 all-time at AT&T Park.