After the Pirates scored four runs in the top of the fifth inning it looked like another wasted day for the Cardinals who had scored just two runs in the previous 18 innings and had just two hits in the game so far.

The Cardinals came back to take the lead in the fifth saw the Pirates tie it in the eighth before the Cardinals scored in the 12th to win 6-5 on Thursday at Busch Stadium.

"There's no question there's something extra that plays into this" manager Mike Matheny said. "We talked about it before the series started we wanted to play different than how we did in Pittsburgh and I think the guys played hard they really did. Any time having a walkoff win is a big deal and having won this series is a big deal and jumping on it again today shows the resiliency of this club. They just kept playing the game right."

"That was a good one" said second baseman Matt Carpenter who went four for five and walked in the 12th and came around to score the winning run. "That was a lot of fun. A big win for us walk-off style. It was big they're the team we're chasing now and the team we're chasing in the division one of our biggest competitors in the division obviously to win that especially in the fashion that we did two walk-off wins in extra innings is a lot of fun and we needed that. Hopefully we can keep this going."

With one out in the 12th Carpenter walked the fifth time he reached in the game and he went to third on a single by Jon Jay through the hole between first and second. Matt Holliday who earlier had extended his hitting streak to 12 games singled up the middle to score Carpenter.

The win gave the Cardinals two wins in the three-game series and cut the Pirates lead in the NL Central back to two games.

The Pirates scored four times in the fifth with a two-run homer by shortstop Clint Barmes off Lance Lynn and a triple by Starling Marte.

The Cardinals then went wild scoring five runs in the fifth on six hits including two doubles and a triple. (Home runs are still taboo for the Cards.) A single by Matt Adams a double by David Freese a single by Daniel Descalso an out by Lance Lynn and a triple by Matt Carpenter cut the Pirates lead to 4-3. An RBI single by Jon Jay tied the game and the Cards went ahead when Pirates center fielder Andrew McCutchen failed on a diving try for a fly ball by Matt Holliday and it went for a double. That was it for Pirates starter A.J. Burnett and the Cardinals had a 5-4 lead.

The Cardinals carried that lead into the eighth when Pirates catcher Russell Martin hit the second pitch from reliever Trevor Rosenthal for a home run to right to tie the game.

Carpenter's double in the fourth was his 40th of the season the most by a Cardinal since Matt Holliday had 45 in 2010. Kevin Siegrist got his first major-league win.