With the score tied 3-3, the Cardinals loaded the bases with two out against Pirates starter Erik Bedard (7-13). Molina (3-for-4) then delivered a ground-rule double, scoring Rafael Furcal and Allen Craig with the go-ahead runs.
Shane Robinson added a two-run double as the Cards evened their three-game series and pulled to within a game of the Pirates for a National League wild card spot.
The rally made a winner of Barret Browning (1-2), who got the final two outs of the fifth inning.
Jason Motte corralled his 28th save despite yielding a run in the ninth. The Pirates loaded the bases with none out, but could get only one run as Motte struck out Garrett Jones and induced a Josh Harrison grounder to end the game.
Bedard allowed five runs on nine hits in a 4 2/3-inning effort.
Jordy Mercer supplied two RBI for the Bucs.