SAN FRANCISCO (AP) — The San Francisco Giants are up three games to one in the National League Championship Series after erasing a 4-1 deficit on Wednesday.

Buster Posey had two hits and three RBIs as the Giants downed the St. Louis Cardinals 6-4. Posey was involved in the Giants' three rallies, lifting a sacrifice fly in the bottom of the first before adding run-scoring singles in the third and sixth innings.

San Francisco took its first lead by scoring three times in the sixth, capped by Posey's RBI hit.

Neither starting pitcher was in the game very long. Giants starter Ryan Vogelsong was pulled after surrendering four runs and seven hits in three innings. Vogelsong served up Kolten Wong's second homer of the series, a solo shot that put the Redbirds ahead 4-1 in the third. Cardinals hurler Shelby Miller didn't last much longer, leaving with two out in the fourth after yielding three runs and six hits. Santiago Casilla worked the ninth for the save.

Winning pitcher Yusmeiro Petit struck out four while tossing three shutout innings. The loss goes to Marco Gonzales, who was reached for three runs on just one hit in two-thirds of an inning.

Matt Holliday had three hits for the Cardinals, who will try to avoid elimination when they play Game 5 on Thursday in San Francisco.

Game 5 is a rematch of the series-opening starters, with Madison Bumgarner going for the Giants against Adam Wainwright.

More From 104.5 THE TEAM