SAN FRANCISCO -- Giants ace Matt Cain didn't make much of his first victory this season, even though it completed a series sweep of divisional rival Los Angeles.
Ending a two-week drought by San Francisco's starting pitchers meant more to the three-time All-Star.
Cain pitched into the eighth inning to end the longest winless-streak of his career, and Hunter Pence accounted for all of the scoring in the Giants 4-3 victory over the Dodgers on Sunday night.
"All of the starters, we just hadn't been throwing the way that we wanted," said Cain, who struck out four and walked three. "All of us wanted to get us off that little skid that we were on. It just took some time."
Cain, who pitched six shutout innings against Los Angeles on opening day, gave up one run and five hits in 7 1-3 innings and allowed only one runner past second base to win for the first time since Sept. 26, 2012.
He left to a standing ovation from the AT&T Park crowd after issuing a one-out walk in the eighth, then watched from the dugout as five relievers teamed for the final five outs.
It's the first win by any San Francisco starting pitcher since April 21 - an 11-game stretch.
"It took us a while ... but it was what we needed," Giants manager Bruce Bochy said. "He got us into the eighth inning, and as usual our boys are entertaining and made it close again. But I was happy for Matt the way he threw the ball."
Sergio Romo worked the ninth for his 12th save, tied for most in the majors.
Hunter Pence doubled twice and drove in four runs, leadoff hitter Andres Torres had three hits and Marco Scutaro added two hits and scored twice for San Francisco.
The Giants extended their season-high winning streak to six games and defeated Los Angeles rookie Hyun-Jin Ryu for the second time this year.
Cain acknowledged the winless streak had begun to wear on him.
"It wasn't something I was proud of," Cain said. "I just wasn't pitching well for the guys. I needed to step it up."
The Dodgers couldn't get out of AT&T Park fast enough. They were the only visiting NL team with a winning record at the Giants waterfront ballpark before the series but are now 60-60 since the stadium opened in 2000.
"I feel better about our club walking out of here right now than I did walking in," said Los Angeles manager Don Mattingly, whose team has dropped three straight one-run games. "We
played them tough the whole series. I feel great about coming out of here."
The Giants won the first two games of the series on game-ending home runs but didn't need any late dramatics this time, though the Dodgers made it close with three runs in the eighth.
San Francisco took an early 2-0 lead off Ryu and made it hold up behind Cain (1-2) and five relievers.
It didn't help that Mattingly had to scratch first baseman Adrian Gonzalez from the lineup with a sore neck less than an hour before first pitch. Gonzalez, who was also scratched from the first two games of the series, delivered a pinch hit two-run single in the eighth before leaving for a pinch runner.
Ryu (3-2) has been one of the most consistent pitchers for Los Angeles except against San Francisco. He gave up 10 hits and three runs while taking the loss in his majors debut on April 2, then allowed eight hits and four runs over six innings in the rematch.
The Giants opened with three straight singles off Ryu in the first but the Dodgers right-hander got out of it allowing only one run. Scutaro scored on Pence's fielder's choice grounder after Buster Posey hit into a forceout at home. Ryu then retired Francisco Peguero on a fly ball to end the inning.
Pence, who was hitting just .211 with runners in scoring position, doubled Scutaro home in the third then hit a two-run double in the fifth to drive in Pablo Sandoval and Posey.
After Cain walked Matt Kemp in the eighth, A.J. Ellis singled off reliever George Kontos and Juan Uribe walked. Gonzalez followed with a two-run single to center and Uribe scored on an infield hit by Dee Gordon to make it 4-3. Jean Machi got pinch hitter Jerry Hairston to ground out with the tying run at second base to end the inning.
Notes: San Francisco CF Angel Pagan did not play because of a strained hamstring and is questionable for Monday's series opener against Philadelphia. ... Opponents are batting just .181 against Giants LHP Madison Bumgarner. Bumgarner (3-0) pitches the first game against the Phillies. ... Chris Capuano (0-1) is scheduled to come off the disabled list and start for Los Angeles on Monday against Colorado.