SAN FRANCISCO (AP) -- The San Diego Padres had chances to win the game in the final two innings. Reliable Giants closer Santiago Casilla shut the door.
Drew Pomeranz was outpitched by Madison Bumgarner and the Padres lost 5-4 to San Francisco on Monday night, missing opportunities late against San Francisco's bullpen.
Center fielder Denard Span robbed Matt Kemp of extra bases in the third with a great catch.
San Diego pulled within 5-4 in the eighth, getting consecutive RBI singles by Alexei Ramirez and pinch-hitter Brett Wallace against Hunter Strickland. Derek Law allowed a hit then Josh Osich relieved with the tying run on third and go-ahead runner at first and struck out Jemile Weeks. Casilla entered and struck out pinch-hitter Jose Pirela, then finished for the four-out save. It was his sixth career save of four or more outs and 100th save of his career.
"Casilla has saved 100 games. He knows what he's doing out there," Padres manager Andy Green said. "We had some pretty good swings against him. We had the winning run on second in the eighth and the winning run at the plate in the ninth. All you can ask is to give yourself a chance."
Bumgarner (2-2) struck out nine in 6 2-3 innings to snap a two-start skid with his first victory in four starts since April 4 at Milwaukee.
Hunter Pence homered, Angel Pagan had three hits and his two RBIs came with two outs, and Buster Posey also homered as the Giants won for the third time in four games following a five-game losing streak.
Pence connected for his fourth home run leading off the fourth to put San Francisco ahead 2-1 and Pagan hit an RBI double four batters later. Pence added a sacrifice fly the next inning. Posey hit his third homer in the seventh.
Bumgarner improved to 6-1 with a 2.69 ERA in 13 home starts against San Diego, including 2-0 with a 0.76 ERA over three outings last year.
San Francisco's top-hitting pitcher, he struck out three times in a game for just the fifth time in his career and first since Sept. 12, 2014, against the Dodgers.
Derek Norris had an RBI double in the sixth for San Diego, which faced San Francisco for the first of 19 matchups this season -- including six meetings in May, three more at AT&T Park. Jon Jay singled in a run for the Padres.
Pomeranz (2-2), coming off a career-best 10 strikeouts against the Pirates his last time out, struck out six more over 4 1-3 innings. He allowed three earned runs on seven hits with three walks and a pair of wild pitches.
"I wasn't going after them like I had been the past few games," Pomeranz said. "I got into a lot of bad counts and that drove my pitch count up. I struggled up in the zone."
Pomeranz's 31 strikeouts over his first four starts rank third in Padres history. The most through four starts are 34 by Jake Peavy -- a current Giants right-hander not pitching this series -- in 2005.
Three plays went to replay review over the final two innings, all of them upheld, including a catch just off the grass by right fielder Kemp that denied the Giants an insurance run to end the eighth.
BUMGARNER'S CHEER CREW
Some 200 veterans donning bright yellow hard hats were in the stands among the sellout crowd supporting Bumgarner, many waving yellow towels in the upper deck of left field. The pitcher, in partnership with Carhartt, through his "Strikeouts for Vets" campaign is having $500 donated from the work clothes company for every strikeout by the lefty. The money goes to Helmets for Hardhats, a nonprofit group that connects veterans to careers in the building and trade industry.
Padres: LHP Robbie Erlin, on the disabled list with a strained pitching elbow, played catch Sunday and is with the Padres on the road. He will keep progressing by extending his distance on flat ground before getting on a mound.
Giants: RHP reliever Sergio Romo is scheduled to play catch Friday to test his strained pitching elbow that landed him on the DL April 15, retroactive to April 11. "That is encouraging," manager Bruce Bochy said. "Trying to get these guys back, they're a big part of our pen." ... Fellow reliever George Kontos, like Romo dealing with a strained flexor tendon, still must go through the throwing sequence beginning from 60 feet out. Bochy expects him to need another two weeks.
Padres: RHP James Shields (0-3) tries again for his first victory of the year. He is 2-1 with a 2.88 ERA in four career starts facing San Francisco, including three 2015 matchups.
Giants: RHP Johnny Cueto (3-1), coming off his first loss last week to Arizona, has won four of his last five starts against the Padres and going 4-1 with a 2.25 ERA.