Dickey (5-7) recovered from two consecutive poor starts to turn in his best game since being acquired by Toronto from the New York Mets and signed to a two-year, $25 million contract in December.
The reigning Cy Young Award winner baffled the Giants on two hits and two walks while striking out five as the Blue Jays split a two-game interleague series.
But as San Francisco's Barry Zito delivered the pitch, Dickey straightened up and poked a grounder past Sandoval that rolled down the left-field line for a 1-0 lead.
He later scored on Jose Bautista's hit and Mark De Rosa capped the outburst with a two-run single.
Zito (4-4) was charged with the loss, surrendering four runs on seven hits over six full innings.
Exploding whale video goes viral on Internet
Couple mistakenly served bag of cash at McDonald's drive-thru