LOS ANGELES (AP) -- The San Francisco Giants are in fourth place in a tight NL West race a year after winning their second World Series title in four years.
The only team trailing them in the standings is the Los Angeles Dodgers, who completed a sweep of the Giants at home for the first time since April 2009.
Clayton Kershaw outpitched Tim Lincecum in the seventh regular-season matchup between the two former Cy Young Award winners, and the Dodgers rallied with three runs in the sixth inning to beat the Giants 4-2 on Wednesday night for a three-game sweep.
"You kind of look forward to it, just because it make you rise to the occasion and pitch better," Lincecum said of his latest showdown with Kershaw. "I was more intent on being aggressive, but I just didn't put pitches where I needed to and when I should have."
When Kershaw won his Cy Young Award in 2011, he was 5-0 with a 1.07 ERA in six starts against the Giants that season -- and four of those victories came in games that Lincecum was the opposing pitcher.
"Hopefully we keep pitching against each other for a long time," Kershaw said. "But it's not a matter of facing him, but facing the eight other guys. And I'm sure he'd say the same thing."
The Giants have lost four in a row and nine of 12, putting themselves a season-worst two games under .500. They are 3 1/2 games behind the division-leading Arizona Diamondbacks.
"It's always tough when you're going through a stretch like we're going through," manager Bruce Bochy said. "The only thing you can do is keep grinding and believe it's going to turn around, which we do."
Lincecum (4-8) gave up four runs and 10 hits in 5 1-3 innings and struck out four. The two-time Cy Young winner is 1-7 with a 5.24 ERA in his last eight starts since beating Atlanta 5-1 on May 12 with seven innings of two-hit ball. The Giants have scored fewer than three runs in six of Lincecum's last eight outings.
Kershaw (6-5) allowed two runs and four hits in eight-plus innings and had seven strikeouts against an offense that totaled just 14 runs over its previous six games while going 8 for 47 with runners in scoring position.
It was the Dodgers' second three-game sweep of the season and first since April 2-4 against Pittsburgh. They got the jump on Lincecum with an RBI single in the third inning by Hanley Ramirez.
But the Giants, who came in batting a league-best .285 against left-handed starters, responded in the fourth with Buster Posey's 10th home run after a leadoff walk to Marco Scutaro. It was first homer by last year's NL MVP in his first 40 career at-bats against Kershaw, and snapped a stretch of 30 consecutive innings in which the Giants hadn't held a lead.
"You can't walk Scutaro leading off that inning, especially after we just got a run," Kershaw said. "I mean, Posey's going to hit homers -- that's what he does -- but it should have been a solo homer."
That lead evaporated in the sixth, when the Dodgers pulled ahead to stay. Andre Ethier delivered the tying run with an RBI single and A.J. Ellis followed with a run-scoring double into the left field corner. Juan Uribe got an infield hit and Lincecum ended his night with a wild pitch to Skip Schumaker that allowed Ellis to score.
"I knew he was getting close, and then after that last pitch, I just said 'That's it,'" Bochy said. "I had Jose (Mujares) ready, and he did a good job getting out of it. But it's not just Timmy. I mean, that sixth inning lately has been a problem for us. The crooked number got us, and their guy did a good job on us."
Lincecum got a break in the fifth on another overaggressive rookie mistake by Yasiel Puig, who tried to stretch a two-out single into a double and was easily thrown out by left fielder Andres Torres. This was Puig's 13th multihit game and sixth with three hits since his big league debut June 3. He is batting. 435 in his first 22 contests.
"He's got good plate coverage with his bat, and he covers the pitches away," Lincecum said. "He also covered two of my changeups in, and they were hits, but I got ground balls out of them -- which is what I wanted. It was just not where I wanted them to go."