The San Francisco Giants scored three runs in the sixth inning to move to the brink of a return to the World Series with a come-from-behind 6-4 win Wednesday night over the St Louis Cardinals.

The victory gives the Giants a 3-1 lead in the best-of-seven National League Championship Series and one more win will send them to the World Series for the third time in five years.

St. Louis first baseman Matt Adams was involved in two fielding incidents that helped San Francisco take the lead in the sixth inning.

Trailing 4-3 in the bottom of the sixth, with runners on second and third, Giants center fielder Gregor Blanco punched a routine shot to Adams but he was slow with his throw to home plate, allowing Juan Perez to tie the scores at 4.

Joe Panik then hit a grounder to Adams, who stepped on first base for the out before throwing wide of second in an attempt to complete a double play. The errant throw allowed Brandon Crawford to score the go-ahead run from third base.

Blanco added an insurance run, scoring from second on a single by Buster Posey's.

"Anytime you can put pressure on the defense you've got the opportunity for good things to happen," Posey told reporters.

"We were able to come up with two big two-out RBIs to get back in the game."

Game 5 is Thursday night in San Francisco and Posey highlighted the importance of closing out the series as soon as possible, aware from personal experience that teams can come back in a best-of-seven series.

"It is very important," said Posey, who drove in three runs. "We were down 3-1 in St Louis two years ago, that's fresh in our minds, we know we are going to have a tough one [Friday]."

After scoring a run apiece in the first inning, the Cardinals were up 4-1 by the middle of the third before the Giants fought back.

Kolten Wong doubled in the top of the second and was brought home by an A.J. Pierzynski single for a 2-1 advantage before Matt Holliday reached home on a ground ball and Wong hit a solo homer in the third to stretch the advantage to three runs.

The Giants responded immediately in the bottom of the inning with Joaquin Arias driven in by a Posey single before the catcher reached home courtesy of a Hunter Pence single to reduce the deficit to a single run.

The NLCS winner will face the Kansas City Royals, who secured a spot in the World Series earlier Wednesday with a four-game sweep of the Baltimore Orioles in the American League Championship Series.