The Giants forced extra innings with a ninth-inning run but Crawford singled on an 0-2 pitch from Jeremy Affeldt (1-5) to open the Los Angeles 10th. He moved to second on a sacrifice bunt from Nick Punto.
Gonzalez and Affeldt battled for seven pitches, with Gonzalez lining the last one through the box and into center. Crawford beat the throw home from center fielder Angel Pagan to end the game.
The win lowered the Dodgers' magic number for clinching the NL West to five. Any combination of five Los Angeles wins or Arizona losses puts the Dodgers back into the playoffs.
Brian Wilson (2-1), who pitched the top of the 10th, collected the win.
Los Angeles went ahead 2-1 in the seventh when Yasiel Puig doubled in Dee Gordon but Dodgers reliever Kenley Jansen was unable to hold the lead. Pablo Sandoval singled to open the ninth and Juan Perez was inserted as a pinch-runner. He stole second and took third on a field's choice before Gregor Blanco singled him in for a 2-2 tie.