Nathan Eovaldi threw six innings for his first win of the year and Elian Herrera clubbed his first major league homer, as the Dodgers beat Arizona, 4-1, to start a four-game series.
Scott Van Slyke also went deep for the NL West leaders, who have won three in a row.
Eovaldi (1-5) scattered five hits and gave up a run to post just his second major league triumph. The 22-year-old right-hander posted a win in his first career appearance, Aug. 6, 2011, but was winless over his next 16 outings.
Scott Elbert and Ronald Belisario each threw a perfect inning and Kenley Jansen struck out the side to earn his 15th save.
The Dodgers, who lost seven in a row from June 24-30, are 1 1/2 games ahead of the Giants in the division.
"We're just scratching for every win we can get now. We regrouped a little and have kind of been able to pitch good," Dodgers manager Don Mattingly said. "We're getting the pitching, now we're able to put a few runs up."
Stephen Drew knocked in the lone run for the Diamondbacks, losers of a season- high six in a row.
Wade Miley (9-5) was charged with eight hits and four runs over 6 2/3 frames to have his four-start home winning streak snapped.
"I left some balls up, I just wasn't executing pitches, missing up in the zone, trying to go away and the ball comes back over the plate. They were making me pay," Miley said.
Mark Ellis doubled with one out in the first and Jerry Hairston Jr. singled. Juan Rivera kept the hit parade going with a double down the left field line, and Luis Cruz lined a single into right for a 2-0 advantage.
"It's such a long season, we've had so many injuries, so many different guys coming in, trying to get that chemistry, that gel together," Ellis said. "I know baseball is a little different sport, so many guys in and out of the lineup, it was bound to happen at some point and hopefully we can get over that now, get over that hump and continue to play good baseball the rest of the way."
Drew's base hit to right plated Paul Goldschmidt in the second, but the Diamondbacks stranded a runner at third when Miley grounded out on a diving stop by Hairston at third.
Van Slyke homered to left in the fourth and Herrera went deep to left in the seventh, the final batter for Miley.
"He wasn't locating the way he was trying to locate," Diamondbacks manager Kirk Gibson said of Miley. "I left him out there one guy too much."
Dodgers shortstop Dee Gordon, who leads the majors in steals, is expected to miss the next six weeks due to a torn ulnar collateral ligament in his right thumb. He was put on the 15-day disabled list and will have surgery on Friday...The Dodgers replaced Gordon on the roster by activating right-handed reliever Javy Guerra from the 15-day DL...The Diamondbacks had their club- record 15-game streak with a homer broken...Arizona second baseman Aaron Hill had his 19-game home hitting streak snapped....LA has won four of the six matchups this season...The Dodgers ended a four-game road skid.