SAN FRANCISCO — It just so happens Jake Smith earned his first major league win against his old Giants franchise, the one that found him on the grounds crew at Class A Augusta, gave him a tryout and, eventually, a place on the team.

Smith capitalized for San Diego when his name got called Tuesday night for a key late inning facing San Francisco.

Ryan Schimpf hit a go-ahead three-run homer with two outs in the ninth inning, and the Giants relievers gave up a lead and chance to gain ground on the division-leading Dodgers in a 6-4 loss to the Padres on Tuesday night.

Smith (1-0) pitched the eighth for his first career victory after San Diego claimed him from the Giants in July, then Kevin Quackenbush finished for his second save as some Giants fans booed.

“Schimpf really did all the work. I just threw up a zero,” Smith said. “I knew all season we had the ability to do stuff like this.”

Hunter Strickland (3-3) started the ninth and allowed two runs, three singles and a bases-loaded walk to Wil Myers, then Steven Okert entered to try to get the final out. Schimpf clobbered the fourth offering and sent it into the center-field bleachers for his 19th homer.

Okert offered no excuses. He was ready to go despite the short notice to warm up.

“It’s September, we’re in the playoff race, you’re checked in the whole game,” he said.

There were two bloopers and a groundball Buster Posey stopped at first base only to have the ball ricochet off his glove on a failed play. The Giants blew their sixth save in 10 September opportunities.

Angel Pagan homered leading off the fifth and Gorkys Hernandez also homered for the Giants, who stayed four games back of NL West-leading Los Angeles after the Dodgers lost earlier at the New York Yankees. San Francisco remained percentage points ahead of the Mets for the top NL wild-card spot.

Hunter Pence hit a run-scoring double and Brandon Crawford had an RBI single for San Francisco, which will host St. Louis for a four-game weekend set and still must play six with the Dodgers among the final 18 games of the season.

“It’s a punch in the stomach,” Giants manager Bruce Bochy said. “You’ve got to bounce back.”

Albert Suarez, who has bounced between the rotation and bullpen, had been in position to win for the first time since June 23 at Pittsburgh — a span of six starts and 10 outings. The right-hander gave up one run and six hits, struck out one and walked two in five innings.

Shut out on five hits a night earlier, the Giants got a unique lineup from Bochy — and not all by design, either.

Posey had been scheduled to have a night off but Bochy used his regular catcher at first base given all of the other regulars not in the lineup. First baseman Brandon Belt was ill.

The Giants lost their fifth straight to San Diego during which they had been outscored 26-14 after winning the initial nine matchups of 2016.

“It’s kind of the same fight we’ve shown all year,” Padres manager Andy Green said. “The results don’t show that. It’s been a very resilient team.”

Padres starter Clayton Richard surrendered a season-high 11 hits in 5 2/3 innings. He allowed three runs, struck out four and walked three in his sixth start of the season for the Padres after signing last month following his release by the Cubs.

TRAINER’S ROOM

Padres: Green still hopes RHP Jon Edwards will return from an elbow strain and pitch before season’s end. He had a platelet-rich plasma and stem cell injection a couple of weeks ago then threw at instructional league Tuesday with plans to do so again. That would be followed by live batting practice. … San Diego hopes RHP Jarred Cosart (hamstring, groin) will be ready to start Sunday’s series finale at Colorado or at the latest Monday against Arizona.

UP NEXT

Padres: RHP Luis Perdomo (7-9, 5.89 ERA) makes his fourth career appearance and second start against the Giants. He is 5-7 with a 4.09 ERA over his last 23 starts.

Giants: LHP Madison Bumgarner (14-8, 2.61) goes for the 100th victory of his career as the series wraps up Wednesday afternoon. He is 3-0 with a 1.19 ERA in his last four home starts vs. San Diego with 38 strikeouts to four walks.