Evan Longoria drove in the go-ahead run with an infield single in the fifth inning after San Diego made two errors, and the San Francisco Giants held off the Padres 4-2 on Wednesday night to complete a two-game sweep.
Kevin Pillar homered for the first time in more than a month and Donovan Solano had two hits and two RBIs for the Giants. Buster Posey went 1 for 4 after coming off the injured list earlier in the day.
San Diego loaded the bases with two outs in the ninth against Will Smith before the closer got Manuel Margot to pop out to second base. Smith's 16 consecutive saves to start the season are the second-most for the Giants since saves became an official stat in 1969.
Shaun Anderson (2-1) pitched four-hit ball over six innings and had a season-high six strikeouts for San Francisco. The rookie has a 3.32 ERA in three June starts after going 0-1 with a 4.80 ERA in three May starts.
Eric Hosmer had an RBI double for the Padres, who committed three errors overall that led to three runs.
San Diego's defense came apart in the fifth.
Steven Duggar singled, went to second on a wild throw by shortstop Fernando Tatis Jr. and scored on Solano's single. As Solano rounded first, left fielder Josh Naylor made a wild throw toward second that sailed out of play for a two-base error. After Brandon Belt walked, Tatis made a diving stop on Longoria's sharp grounder but threw wide of second as Solano scored.
Longoria also drove in the go-ahead run of San Francisco's 6-5 win over San Diego on Tuesday.
The Giants added another unearned run in the seventh following a throwing error by Padres reliever Robbie Erlin.
Sam Dyson and Tony Watson retired three batters apiece for San Francisco.
Padres starter Joey Lucchesi (5-4) allowed three runs and five hits in six innings. Lucchesi, who beat the Giants on March 29, had six strikeouts and two walks.
Giants: Posey missed eight games with a right hamstring injury sustained June 1 in Baltimore. . Belt returned to the lineup after being limited to a pinch-hitting appearance Tuesday because of a sore neck.
Padres: LHP Matt Strahm (2-5, 4.03 ERA) is expected to come off the injured list to start against the Rockies in the opener of a four-game series at Colorado on Thursday. Strahm has been out with a left rib strain.
Giants: LHP Drew Pomeranz (1-6, 7.16 ERA) tries to get his rocky season back on course against Milwaukee on Friday. Pomeranz is winless in his last five starts and has the seventh-highest ERA among pitchers with at least 40 innings.