San Diego faced a 3-0 deficit heading into the seventh, but got single runs in the seventh and eighth and then exploded for a game-winning outburst in the ninth against Juan Gutierrez (0-1).
Gutierrez walked Nick Hundley to open the ninth and Jerry Hairston sacrificed Hundley to second. Everth Cabrera then struck out, but David Eckstein doubled on the first pitch to bring home Hundley and tie the game.
Adrian Gonzalez was intentionally walked to bring up Headley, who hit his first home run of the season.
The win went to Heath Bell (1-0), who worked a perfect top of the ninth.
Arizona wasted an outstanding start by Edwin Jackson, who threw six shutout innings while giving up three hits with three strikeouts.