ST. LOUIS -

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.

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.

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.