Updated

James Loney drove in the go-ahead run with a groundout in the sixth inning and the Dodgers avoided a four-game sweep with an 8-3 win over the Mets on Sunday.

Loney's groundout gave Los Angeles its first lead in 66 innings. He added an RBI double as part of a four-run seventh, helping the Dodgers halt a season- high seven-game losing streak.

All-Star Clayton Kershaw (6-4) got the win, allowing three runs -- one earned -- on five hits over seven innings. He walked three and struck out nine.

The two unearned runs came courtesy of consecutive third-inning errors by Dee Gordon, who atoned with an RBI and run scored later in the game.

Dillon Gee (5-7) took the loss for the Mets, winners of a four straight entering Sunday. He gave up four runs -- two earned -- on five hits and two walks over six innings.

"We didn't play good tonight," said Mets manager Terry Collins. "Dillon pitched good and we didn't help him. We just had a bad night tonight."

Scott Hairston had a first-inning RBI single in the setback.

Juan Rivera tied the game with an RBI double in the bottom half, but Gordon's gaffes allowed New York to reclaim the lead.

With runners at first and second and one down, David Wright hit a grounder to second baseman Adam Kennedy, who initiated a potential double play with a flip to Gordon. The shortstop tagged second base, but his throw to first was wide, allowing Gee to score.

On the next play, Gordon fielded a grounder from Hairston, then threw a one- hopper to first, which was bobbled by Loney, allowing Wright to cross the plate for a 3-1 lead.

Gordon was somewhat vindicated in the fifth when he plated Juan Uribe with a high chopper towards first, which was misplayed by Justin Turner. A.J. Ellis followed with a game-tying sac fly, scoring Tony Gwynn, who reached on an error by Ronny Cedeno.

An inning later, Rivera drew a leadoff walk, advanced to third on Kennedy's ground-rule double, and scored the go-ahead run on Loney's groundout to Cedeno.

Kennedy added a sac fly in the seventh and a pair of runs scored on an error by catcher Mike Nickeas.

"A great game for us. We took advantage of their mistakes," said Kershaw. "We went through a rough patch but hopefully we got out of it tonight. It feels good to win."

Game Notes

Kershaw improved to 5-0 in six career starts against the Mets...The Dodgers' seven-game losing streak was their longest since they dropped eight straight games in 2008...Kershaw and injured outfielder Matt Kemp were named to the National League All-Star team for the Dodgers, while pitcher R.A. Dickey and Wright made it for the Mets.