Lewis, pinch-hitting, drove in two runs to tie the game with his hit off the right field wall.
San Diego then intentionally walked a batter to get runners at the corners, setting up a potential double play. Jose Castillo hit a grounder to Padres' shortstop Edgar Gonzalez, who hesitated, making no throw, while Lewis dashed home with the winning run. Castillo was credited with an infield single.
Adrian Gonzalez had hit a two-run homer to put San Diego ahead 3-1 in the top of the 10th.
The Giants have won seven of their last 11 games.
Alex Hinshaw (1-0) got his first major league win despite giving up Gonzalez' homer.
Trevor Hoffman (0-4), victim of the Giants' 10th inning rally, took the loss.
Aaron Carter is still in love with Hilary Duff
Boston schools pull out free condoms over wrapping complaints