St. Louis, MO (Sports Network) - After surviving a 19-inning marathon, the Pittsburgh Pirates placed ahead of the St. Louis Cardinals on the scoreboard, 6-3, and in the standings.

Pedro Alvarez crushed a 1-2 slider over the center-field fence for a solo homer in the 19th to give the Pirates the win and put them two games ahead of St. Louis for the second wild card in the National League.

"We kept playing defense, we kept pitching. At the end of the day, we finally got some separation in the 19th inning," Pirates manager Clint Hurdle said.

Barret Browning (1-3), who picked up his first career win on Saturday, took the loss after allowing the home run with one out in the top of the 19th.

Pittsburgh continued the rally after the home run. Clint Barmes singled and Jose Tabata doubled with two outs. Josh Harrison worked a walk before Andrew McCutchen laced a two-run single into right field to open up a 6-3 lead.

Wandy Rodriguez (8-12), who was scheduled to start for the Pirates on Monday against San Diego, stranded runners on the corners in the 18th inning and closed out the game in the 19th.

The Pirates took the lead in the 17th inning when pitcher James McDonald lined a one-out, pinch-hit single. Joe Kelly uncorked a wild pitch then intentionally walked Alvarez with two outs. He proceeded to hit Barmes to load the bases.

The Cardinals gave the ball to Marc Zzepczynski, but he was only able to deflect Garrett Jones' slow ground ball, allowing McDonald to score the go- ahead run.

St. Louis came back to tie the game in the bottom half. Yadier Molina led off with a base hit before Skip Schumaker lined a single to center field, which bounced past McCutchen and allowed Molina to reach third. After Rafael Furcal lined out, Tony Cruz lofted a sacrifice fly to left field to tie the game.

The Cardinals jumped out to an early two-run lead when Allen Craig singled and Matt Holliday walked before Beltran lined a two-run double in the fourth.

Pittsburgh tied the game with a pair of unearned runs in the sixth. Barmes led off with a single and Jaime Garcia mishandled a bunt to put runners on first and second with no outs. After Tabata laid down a successful sacrifice, Harrison's sac fly scored a run and moved Jeff Karstens to third. McCutchen legged out an infield single to tie the game at two.

Harrison's liner to the right-field corner put a runner on third with one out in the 11th inning. But after Edward Mujica intentionally walked McCutchen, pinch-hitter Neil Walker grounded into an inning-ending double play.

Garcia, who returned for his first start since June 5, started the game and held the Pirates to a pair of unearned runs on five hits in eight innings. The left-hander had a career-high 10 strikeouts and did not issue a walk.

Garcia's return forced Kelly to the bullpen. Kelly threw 5 2/3 innings of relief and allowed one run on four hits with four strikeouts.

Karstens matched Garcia pitch-for-pitch, allowing two runs on two hits and a walk in seven innings. He fanned four and walked one.

Game Notes

Time of game: 6:07 ... Rodriguez made his first relief appearance since Oct. 1, 2006 ... The game was the longest for either team this season ... Alvarez has knocked in 16 runs against the Cardinals this season, most of any major leaguer ... Pirates reliever Jason Grilli pitched a scoreless inning of relief and struck out two, establishing a new season-high for strikeouts with 70 ... The two teams combined to throw 574 pitches... Alvarez's homer was the latest home run by inning since Mike Cameron hit a 19th-inning homer for the Seattle Mariners against the Boston Red Sox on August 1, 2000 ... The last time the Pirates won a 19-inning road game was August 25, 1979 against the San Diego Padres.