Updated

Clayton Kershaw dazzled San Francisco hitters over eight-plus innings to lead the Los Angeles Dodgers to a 4-2 win over the Giants on Wednesday.

Kershaw (6-5) gave up just two runs on four hits while striking out seven to earn his first win since May 20.

"Clayton looked pretty good. They were aggressive and tried to get him early. When Clayton is hitting both sides of the plate he's tough," said Dodgers manager Don Mattingly.

Kenley Jansen stranded a pair of runners in the ninth to notch his sixth save of the season.

Hanley Ramirez, Andre Ethier and A.J. Ellis each drove in a run for the Dodgers, winners in five straight.

Tim Lincecum (4-8) allowed four runs on 10 hits over 5 1/3 innings to absorb his third loss in four starts.

Buster Posey went 3-for-4 with a two-run homer for the Giants, who have dropped four straight games.

The Dodgers got on the board in the third inning. With two on and one out, Ramirez ripped a base hit to center field to score Mark Ellis to give Los Angeles a 1-0 lead.

Posey cracked his two-run shot in the fourth to put the Giants up 2-1. Marco Scutaro walked before Posey belted his 10th longball of the season into the left-field seats.

Los Angeles pushed three runs across in he sixth to take the lead for good. Ramirez singled, stole second then scored on Ethier's base hit to right field. Ellis followed with a double to left to plate Ethier before coming around on Lincecum's wild pitch.

Scutaro opened the ninth with a base hit to right, spelling the end of Kershaw's night. Los Angeles turned to Jansen, who gave up a base hit to Posey to put two on with no outs. Jansen, though, struck out the next two hitters before getting Brandon Belt to pop out to end the game.

"The sixth inning has been a problem for us. Tim's stuff was good, he threw the ball well, but we shot ourselves in the foot. We had a chance in the ninth, but their guy did a good job on us," said Giants manager Bruce Bochy.

Game Notes

Los Angeles will open a four-game set with the Philadelphia Phillies on Thursday at Dodger Stadium ... Los Angeles outfielder Yasiel Puig, who went 3- for-4, has notched multi-hit performances in 13 of his first 22 games this season ... The Giants (38-40) fell two games below .500 for the first time since they were 15-17 on May 11, 2012.