Padres pitchers retired 23 of the final 24 batters and the Giants didn't get a hit after the second inning.
The Giants had scored only one run in each of their previous three games.
Lincecum (1-1) was chased by Nick Hundley's first homer of the season, on the first pitch of the seventh inning that pulled the Padres to 4-3. Lincecum allowed three runs and seven hits, struck out seven and walked three.
Sergio Romo pitched the ninth for his fifth save in as many chances. He issued a leadoff walk to Chase Headley, who advanced on a wild pitch. Romo got pinch-hitter Yasmani Grandal to pop up to shortstop, Hundley to fly out to left and pinch-hitter Yonder Alonso to fly out to center.
Lincecum improved to 14-6 in 27 starts against San Diego, his most against any opponent. Lincecum threw his first career no-hitter at Petco Park on July 13.
San Diego had one run taken away via instant replay. Chase Headley hit a bases-loaded double down the right-field line in the third, with Will Venable, Seth Smith and Xavier Nady scoring. Nady originally was called safe after sliding in, but Giants manager Bruce Bochy challenged and the call was reversed, with Nady being called out. Replays showed Posey made the tag in time. That pulled the Padres to 4-2.
Walks hurt Padres starter Robbie Erlin (1-2).
Posey homered an estimated 427 feet to left-center on the first pitch he saw from Erlin in the first, his fourth. Hunter Pence was aboard on a one-out walk.
Angel Pagan hit a two-run, bases-loaded single with one out in the second. Erlin had loaded the bases by walking Brandon Hicks, allowing a single by Brandon Crawford and walking Lincecum.
Erlin allowed four runs and three hits in six innings, walked three and struck out three. After allowing the two-run single by Pagan, Erlin retired his final 14 batters.
NOTES: Lincecum improved to 8-3 with a 2.68 ERA in 15 career starts at Petco Park. ... San Diego 2B Jedd Gyorko got the day off. He had played every inning of the Padres' first 18 games. Alexi Amarista started in his place. ... Giants 3B Pablo Sandoval sat out. He was hitting just .171. ... The Giants head to Colorado, where they open a three-game series Monday night, with RHP Ryan Vogelsong (0-0, 5.40) scheduled to face LHP Jorge De La Rosa (0-3, 7.58). The Padres will be at Milwaukee to start a three-game set, with RHP Andrew Cashner (2-1, 1.27) scheduled to oppose RHP Wily Peralta (2-0, 1.96).