The Dodgers came into the ninth trailing 4-3 and were looking at the possibility of falling 5 1/2 games behind National League West-leading San Francisco, which had beaten the Chicago Cubs earlier Sunday.
Gonzalez then came up and laced an 0-2 pitch down the right field line and into the corner, sending both runners home to salvage a victory for the Dodgers.
Ronald Belisario (4-1) earned the win with a scoreless top of the ninth for Los Angeles, which split a four-game series with the D-backs.
Puzzle-maker slips 'Murdoch Is Evil' into Rupert Murdoch's Sunday Telegraph
N.J. man wakes up from 10-hour sleep with knife in back