The San Francisco Giants will take on the St. Louis Cardinals in the National League Championship Series after eliminating the Washington Nationals with a 3-2 Game 4 win Tuesday night.

The Giants sealed the best-of-five Division playoffs 3-1, setting up a rematch of the 2012 Championship Series with the Cardinals, who earlier knocked out the Dodgers.

A wild pitch from Aaron Barrett with bases loaded in the bottom of the seventh proved decisive, allowing Joe Panik home for the winning run after Buster Posey singled and Hunter Pence was walked.

That followed a second inning meltdown for the Nationals, with starting pitcher Gio Gonzalez walking Gregor Blanco with the bases loaded.

Juan Perez, who had reached base on an error, flashed home to double the advantage as Panik ground out to first.

Washington halved the advantage in the top of the fifth when Ian Desmond was driven in from first by a Bryce Harper double to left field.

For a second it appeared Jayson Werth might tie the scores in the sixth only to have Giants right fielder Pence brilliantly throw himself against the outfield fence to make a great catch.

"It's outstanding. It's been a remarkable journey, I wouldn't trade it for the world," Pence told reporters.

"This group, to take the field in this stadium, with this team and these fans, it's truly a blessing."

But Harper wasn't finished putting his stamp on the contest, coming up big in the top of the seventh with a solo home run into the bay over right field against reliever Hunter Strickland to bring the score to 2-2.

Sadly for Nats fans, Harper's shot was nullified by the wild pitch and while he reached base on a walk with two outs in the ninth, Ramos ground out.

The Giants have now won seven straight series in October when added to their 2010 and 2012 World Series winning years.

"We go as hard as we can and we give it all we got (in October)," Pence said.