ST. LOUIS (AP) -- Pedro Alvarez homered in the 19th inning and the Pittsburgh Pirates won the longest game in the majors this season, outlasting the St. Louis Cardinals 6-3 Sunday.
It took 6 hours, 7 minutes to finish. Both teams scored a run in the 17th, and each club used eight pitchers.
Alvarez hit his 23rd homer, a solo shot off Barret Browning (1-3). Andrew McCutchen added a two-run single later in the inning.
Will the Cards make the playoffs this season? Share your thoughts.
Wandy Rodriguez (8-12), who was set to start for the Pirates on Monday night at San Diego, got the win with two scoreless innings of relief.
About 9,000 fans from the original crowd of more than 43,000 stayed until the end. This was the longest game by innings in the big leagues this year. At 6:07, it tied for the longest by time, matching a game between Baltimore and Boston on May 6.
Each team had played a marathon in recent years. St. Louis went 20 innings against the Mets on April 17, 2010, and Pittsburgh played 19 innings at Atlanta on July 26, 2011.
The Pirates improved to 4-0 in extra innings this season. They moved two games ahead of St. Louis in the race for the last wild card spot in the NL. The Cardinals have lost three of four overall.
Both teams ran out of position players after the 18th inning.
Garrett Jones gave Pittsburgh a short-lived 3-2 lead with a bases-loaded infield single in the 17th. He drove in pitcher James McDonald, who singled as a pinch-hitter.
But St. Louis came right back to tie it on a sacrifice fly by Tony Cruz that brought in pinch-runner Ryan Jackson. Yadier Molina and Skip Schumaker began the 17th inning with singles.
St. Louis left-hander Jaime Garcia, sidelined for 64 days with a strain in his pitcher shoulder, struck out a career-high 10 and did not allow an earned run in an eight-inning, 107-pitch stint. He gave up five hits, two unearned runs and did not walk a batter.
Pittsburgh had a pair of hits in the 16th but Molina threw out Jose Tabata trying to steal and reliever Joe Kelly induced McCutchen to ground out to end the inning. Reliever Edward Mujica got Neil Walker to ground into a double play to end the 11th.
Carlos Beltran put St. Louis in front with a two-run double in the fourth, and also stole three bases. Beltran leads the NL with 85 RBIs.
Pittsburgh starter Jeff Karstens gave up two runs on two hits over seven innings. He struck four and walked one.
The Pirates scored twice in the sixth to tie it on a pair of infield singles and Garcia's throwing error. Clint Barmes reached on an infield hits and Garcia mishandled a bunt attempt by Karstens. Josh Harrison drove in Barmes with a sacrifice fly and McCutchen followed with an infield single.
NOTES: Garcia's 10 strikeouts are the most by a St. Louis left-hander since Mark Mulder fanned 12 on May 9, 2005 against Los Angeles. ... The Cardinals sent RHP Trevor Rosenthal to Triple-A Memphis prior to the game to make room for Garcia. .... St. Louis plays host to Houston in a three-game set beginning Tuesday. Wainwright (11-10, 3.87) will face Lucas Harrell (10-8, 3.81) in the series opener. Wainwright drew a walk as a pinch hitter Sunday. ... Pittsburgh closes out a six-game road trip with three at San Diego starting Monday. ... Pirates 2B Neil Walker did not start for the fourth successive game with a dislocated pinky on his right hand. He later pinch hit. ... Molina grounded out to second to finish a 14-pitch at-bat in the fourth.