San Diego's season-high, five-game winning streak was snapped.
After Joe Panik's sacrifice fly put San Francisco ahead 2-1 in the seventh, the Padres scored two runs in the bottom of the inning.
Yasmani Grandal doubled with one out off of Jean Machi and scored the tying run on Jake Goebbert's triple into the right-center field gap. Cameron Maybin followed with a sacrifice fly that easily scored Goebbert.
Hudson had his second strong outing to break a three-start losing streak. Hudson gave up one run on three hits over six innings and avoided matching his career high for losses in consecutive starts. He struck out four and didn't walk a batter.
The Padres tied it in the sixth on Seth Smith's sacrifice fly with one out after consecutive singles by Brooks Conrad and Alexi Amarista to open the inning.
Gregor Blanco hit his first homer of the season to give the Giants a 1-0 lead in the second.
Cuban defector Odrisamer Despaigne made his third career start for San Diego since being called up from the minors last month. The 27-year-old right-hander, who beat the Giants in his major league debut on June 23, wasn't as sharp this time.
He overcame four walks and allowed one run and two hits over six innings, his shortest outing. In three starts since coming up from the minors, Despaigne has an ERA of 1.41.
San Francisco third baseman Pablo Sandoval left the game in the first inning with a bruised left elbow after he swung and missed a pitch that hit him.
NOTES: San Diego was the only team that hadn't blown a lead after seven innings this season, going 29-0. ... Pence extended his hitting streak to 10 games with an infield single to open the game. ... The Padres have given up three homers in a game only twice this season, second lowest to the Chicago Cubs (1). ... Giants RHP Tim Lincecum (7-5, 4.06 ERA) will face Padres RHP Jesse Hahn (4-1, 1.95) in Sunday's series finale.