Sanchez erased a 1-0 deficit in the second inning with a run-scoring groundout, then delivered a two-run double in the fourth for a 3-1 Giants lead.
Petit (2-0) struck out 10, yielding two runs on seven hits with a walk.
The rookie right-hander, making his second major league, also provided an RBI single as the Giants took 2-of-3 from the Diamondbacks.
Arizona's Patrick Corbin (13-5) was tagged for five runs on nine hits over five full innings.
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need
Beyonce flaunts bikini body, Blue Ivy in vacation pics