LOS ANGELES -- Dan Haren is back in a groove after enduring the worst stretch of his career throughout most of July.
Haren (12-10) allowed one run and four hits in six innings against his former team. He struck out six and walked one, improving to 4-1 with a 2.04 ERA since Aug. 6.
Haren stumbled through five consecutive losses from July 5 to Aug. 1.
"Absolutely I lost my confidence," he said.
Dodgers catcher A.J. Ellis said the rest of the team couldn't tell.
"He didn't show it to us, which is the sign of a great teammate," Ellis said. "I'm really happy for him that he turned it around."
Haren even singled to center in the second when the bunt sign was removed after two strikes. His 12th win marked the first time since 1985 that the Dodgers have had four pitchers with 12 or more in a season.
"I've got four starts left here and I need to make them as good as I can for the team," said Haren, who signed a one-year deal last fall. "We've got to win these."
Kenley Jansen worked a perfect ninth, becoming the fourth Dodgers reliever to save 40 games in a season and the first since Eric Gagne in 2004. Jansen blew his fifth chance of the year Wednesday while attempting a four-out save in the team's 14-inning loss to Washington.
He tossed the landmark ball into the crowd.
"I should have kept that ball, but that kid will enjoy that ball," he said.
After losing four of their previous six, the Dodgers stayed two games ahead of second-place San Francisco in the NL West. Seventeen of Los Angeles' final 21 games are against division opponents.
"Our schedule ain't as easy as it looks," Kemp said. "We need everybody to step their game up here in September. These next couple of weeks are going to be very important for us."
Vidal Nuno (0-5) gave up two runs and seven hits in seven innings, struck out five and walked two. The left-hander hasn't won since June 27 against Boston. He retired a career-best 22 straight batters until giving up a two-out single to Adrian Gonzalez in the first.
"The first three innings were a little difficult. I was missing my spots," Nuno said. "I just found it in the third, after the home run, and just settled down a little bit and just threw strikes and not be in the middle of the plate."
The Dodgers got just enough offense to eke out the win.
Yasiel Puig's slump continued after an 0-for-3 effort, including a strikeout and a walk. He is 4 for 40 with one extra-base hit in his last 15 games.
Kemp led off the third with his 18th homer, sending an 0-1 pitch into the Arizona bullpen in right field.
The Dodgers led 1-0 on Hanley Ramirez's RBI single with two outs in the second that scored A.J. Ellis, who walked.
Arizona closed to 2-1 in the fourth on Didi Gregorius' sacrifice fly.
"We tried to stay as selective as we could depending on how Dan ended up attacking us. But he was throwing strikes," Diamondbacks first baseman Mark Trumbo said. "We had to be aggressive."
The Diamondbacks have allowed three runs or fewer in nine straight games, tying the club's longest streak since Sept. 25, 2005, to April 5, 2006.
After hitting his 175th homer, Kemp is two behind Mike Piazza for fourth in Dodgers history. Kemp extended his season high-tying hitting streak to 11 games since Aug. 22, during which he's batting .364 with five doubles, three homers and 11 RBIs.
Diamondbacks: Relief pitcher Brad Ziegler will have season-ending surgery on his left knee Tuesday to repair frayed cartilage under the kneecap.
Dodgers: LHP Paco Rodriguez, on the disabled list since Aug. 4 with a shoulder strain, had a setback. He was sore on Thursday, a day after his bullpen session, so a simulated game set for Friday was scrubbed. Manager Don Mattingly said he still thinks there's time for Rodriguez to return this season.
Diamondbacks: Chase Anderson (8-6, 3.75 ERA) starts and is one-third of an inning shy of tying his career best of 137 2/3 innings pitched in 2012. He's allowed two runs or fewer in six of his last nine starts.
Dodgers: Left-hander Hyun-Jin Ryu (14-6, 3.18 ERA) takes the mound. He is 2-0 with 0.00 ERA against the Diamondbacks this season.