Trailing 4-3, the Pirates erupted for three runs in the eighth to take control of the game.
Ryan Doumit's one-out double off Marc Rzepczynski (0-2) drove in pinch-runner Chase d'Arnaud to tie the score. Ryan Ludwick was intentionally walked and one out later pinch-hitter Jason Jaramillo drew an unintentional walk to load the bases.
Cardinals closer Fernando Salas then came in to pitch and Ciriaco greeted him by slicing a 1-2 pitch past first baseman Albert Pujols and down the right-field line, sending home the two key runs.
Jason Grilli (2-1) earned the victory with a scoreless top of the eighth and Joel Hanrahan picked up his 37th save despite allowing a run to score on a wild pitch in the ninth.
Pujols drove in three with a two-run homer and sacrifice fly for the Cardinals, who came into the game trailing National League wild-card chase leader Atlanta by 4 1/2 games.
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'
Beyonce flaunts bikini body, Blue Ivy in vacation pics