Richard sets down 18 of 21 in Padres' 6-2 win over GiantsSan Diego Padres' Eric Hosmer, right, celebrates with teammate Cory Spangenberg after the team's 6-2 win over the San Francisco Giants in a baseball game Friday, June 22, 2018, in San Francisco. (AP Photo/Marcio Jose Sanchez)
It also assured Clayton Richard's career-best winning streak stayed intact.
Hosmer reached base three times, Richard pitched three-hit ball over six innings for his fourth consecutive win and San Diego beat the San Francisco Giants 6-2 on Friday night.
The Padres were clinging to a 3-2 lead in the ninth before scoring three times. Hosmer's two-run single to left off Will Smith was the pivotal blow and came after the Giants intentionally walked Wil Myers.
''I don't think he likes having the guy in front of him intentionally walked,'' Padres manager Andy Green said. ''He's got way too much pride for that to happen. It was a great at-bat. We needed those two insurance runs.''
Hosmer's hit in the ninth was in stark contrast to his infield single in the third off starter Chris Stratton. The ball bounced near the plate then rolled slowly down the line as third baseman Pablo Sandoval stood and watched, hoping it would go foul. It didn't.
''I didn't even know it had a chance of staying fair, honestly, so it was kind of a surprise for me,'' Hosmer said. ''I'll take the free knocks. I need them, that's for sure.''
Richard (7-6) was dominant in his third start against the Giants this season. He retired 17 straight during one stretch, allowed only two runners past second base and struck out four. The four consecutive wins mark a career high for the left-hander.
''We've struggled the last five days so it's good to get back on the right track,'' Richard said. ''That's always a good thing, and to do it against the Giants here, it's a good win.''
San Diego's bullpen made Richard's performance hold up, but it was dicey at times.
Green used three relievers to get out of the seventh. Kirby Yates allowed a leadoff single in the eighth before setting down the next three. Brad Hand retired all three batters he faced in the ninth.
Gorkys Hernandez doubled twice off Richard.
''We just couldn't do much offensively,'' Giants manager Bruce Bochy said. ''We hit a lot of ground balls off of Richard. That's what he induces with that sinker and we just couldn't get much going offensively.''
San Diego scored the go-ahead run in the sixth on a throwing error by catcher Nick Hundley.
Spangenberg slid into first base with an infield single after initially being called out. After Freddy Galvis singled Spangenberg to third, Hundley blocked a wild pitch by starting pitcher Chris Stratton but threw the ball into center field, allowing Spangenberg to score.
''We had him,'' Bochy said. ''Nick recovered well. He just yanked the throw a little bit to the left.''
Margot followed with an RBI single.
Sandoval's two-out single in the seventh off Craig Stammen trimmed San Diego's lead to 3-2.
Stratton (8-5) allowed three runs and nine hits in six innings but was more upset at himself for not getting to first base on Spangenberg's infield single in the sixth. Giants first baseman Buster Posey made a diving stop but Stratton was late to the bag.
''My thought was that it probably was going to go foul there, but Buster made a heck of a play there and you can't be late,'' Stratton said.
Padres: C Austin Hedges (elbow tendinitis) continues to make progress in his rehab start with Triple-A El Paso and could rejoin the team soon. The Chihuahuas are playing a series against San Francisco's affiliate in Sacramento, about 80 minutes north AT&T Park.
Giants: The team is undecided what the next step will be for Jeff Samardzija after the right-hander gave up four runs in four innings with Triple-A Sacramento on Thursday. Manager Bruce Bochy said it's possible Samardzija will make at least one more rehab start before rejoining the big league club.
RHP Jordan Lyles (2-4, 4.46 ERA) pitches for San Diego on Saturday in the third game of the series. It will be Lyles' ninth start, his most since 2015. LHP Andrew Suarez (2-4, 4.70) goes for San Francisco.
More AP baseball: https://apnews.com/tag/MLBbaseball