SAN DIEGO — Matt Cain knows he doesn't have time to settle in after returning to the San Francisco Giants following a long layoff.
He pitched like it on Wednesday, throwing six strong innings to help the Giants beat the San Diego Padres 7-1. Brandon Belt hit a tying solo home run in the sixth inning and Buster Posey hit a go-ahead, two-run double in the seventh.
Cain (2-1) allowed one run and five hits in six innings, with six strikeouts and one walk. He was making his fourth start of the season. He had elbow surgery in 2014 and had been sidelined this season with a strained flexor tendon.
His only mistake was a home run by Jedd Gyorko leading off the second.
"The first couple of innings it was a little erratic," he said of his fastball command. "It was just one of those where luckily it was missing enough where it wasn't going over the plate where guys could put the good part of the wood on it. I settled down later on, which was definitely a benefit."
Manager Bruce Bochy said Cain pitched better than in his last start, when he went five innings in a no-decision at Arizona.
"He really hit his spots much better than the last outing, where he had trouble getting the ball where he wanted," Bochy said. "He gave us some length, got his pitch count up and that should help him. Great job by Matty."
The Giants are 2½ games behind NL West leader Los Angeles and are in the mix for the second wild-card spot.
Bochy said it was important that Cain had adequate rehab time.
"All these starts are crucial," Bochy said. "We're in the back half now. We're not in a position where we can get a guy ready here."
"The biggest thing is to be getting back out there and having fun with it," Cain said. "Everything is coming back together, being able to throw with these guys after having such a long break. It's just getting back out there, getting back into routine and giving these guys a real good chance to win."
Padres ace James Shields left with a 1-0 lead after throwing 96 pitches in five innings, and the bullpen promptly gave up the lead.
"I was still good to go," said Shields, who added that he understood interim manager Pat Murphy's decision. "I had plenty more in the tank. I've been in that situation plenty of times in my career and I definitely had more in the tank."
Murphy said it was a combination of things, including the pitch count and Shields working hard.
"A certain part of the order coming up that I knew (Marcus) Mateo could get out of," Murphy added. "The pitcher is leading off, a one-run game. I think James understood it, too. A baseball decision. I still felt after the sixth it was a good one."
Belt homered into the sandy play area beyond the fence in right-center on a 3-2 pitch from Mateo with two outs in the sixth. It was Belt's 10th.
Brandon Maurer (6-3) came on for the seventh and allowed Angel Pagan's one-out single before getting Joe Panik to ground to first. He walked Matt Duffy, who checked his swing on a 3-2 pitch, before Posey doubled to right, with the ball landing just in front of a diving Matt Kemp to give the Giants a 3-1 lead. Hunter Pence singled to right-center to bring in Posey.
The Giants piled on with three more runs against Dale Thayer in the eighth. Brandon Crawford hit a leadoff homer into the Jack Daniels' party deck atop the wall in right field, his 14th. Justin Maxwell had a pinch-hit RBI single and Duffy had an RBI base hit.
Shields, coming off his first victory since June 3, held the Giants to three hits in five scoreless innings while striking out seven and walking three.
Gyorko's homer was his fifth.
Giants: LHP Jeremy Affeldt, sidelined since June 16 with a strained left shoulder, was activated from the 15-day DL. He faced two batters in the eighth, allowing a single and a walk. To make room, LHP Josh Osich was optioned to Triple-A Sacramento.
Giants: San Francisco is off Thursday. RHP Jake Peavy (1-4, 4.94 ERA) is scheduled to start when San Francisco opens a three-game home series against Oakland on Friday. The A's will counter with RHP Jesse Chavez (5-9, 3.21).
Padres: RHP Tyson Ross (6-7, 3.38) is scheduled to start the opener of a four-game series against Miami. The Marlins counter with RHP Tom Koehler (7-6, 3.38).