Pittsburgh came back from an early 5-2 deficit to win its third in a row.
The Pirates rang up 19 hits against five St. Louis pitchers and scored 12 times over the final five innings.
The bases-loaded double by Alvarez brought about a 5-5 tie and Pittsburgh then scored four times in the sixth on solo homers by Clint Barmes and Alex Presley along with a two-run shot by Garrett Jones.
Andrew McCutchen hit a three-run homer in the ninth to finish off Pittsburgh's late-game onslaught.
Kevin Correia (4-6) gave up five runs on six hits in five innings, but still got the win.
The first seven Pittsburgh runs were charged to Adam Wainwright (6-8).
2014: NFL Cheerleaders [PHOTOS]
Julius Randle breaks leg during NBA debut