Gonzalez clubbed a 450-foot solo homer into the right-field bleachers in the third inning, putting the Dodgers ahead to stay at 3-2, and then added another bases-empty shot in the eighth to cap the Dodgers' scoring.
In between, Carl Crawford and A.J. Ellis also went deep for the Dodgers, who avoided elimination and cut the Cardinals' NLCS series lead to 3-2.
Zack Greinke (1-0) allowed two runs on six hits over seven innings, walking one and striking out four while driving in a run in a must-win situation.
Dodgers closer Kenley Jansen allowed two runs in the ninth but struck out pinch-Hitter Adron Chambers for the final out.
Cards starter Joe Kelly (0-1) was roughed up for four runs on seven hits in a five-inning stint.