PHOENIX -- Hanley Ramirez and A.J. Ellis hit back-to-back home runs to open the top of the 14th inning, giving the surging Los Angeles Dodgers a 7-5 victory over Arizona and completing a three-game series sweep Wednesday.
Ramirez hit the first pitch from Josh Collmenter (4-2) for his eighth homer of the season, and Ellis hit his fourth homer five pitches later.
Ramirez had three hits and was a triple short of the cycle a day after his career-high 19-game hitting streak was broken.
Kenley Jansen (3-3) gave up a leadoff single to Paul Goldschmidt in the last of the 13th inning but did not allow another hit in his two innings.
The Dodgers (46-46) have won four straight and 15 of their last 18 and reached .500 for the first time since April 30. They have gained seven games on NL West-leading Arizona (47-44) since the teams last met June 12.
Los Angeles tied the game off Heath Bell in the ninth inning. Adrian Gonzalez walked on a 3-2 pitch with two outs before Ramirez and Ellis singled, scoring pinch-runner Jerry Hairston Jr. Bell has five of the D-backs' major-league-high 19 blown saves.
Ellis also had three of the Dodgers' 15 hits.
Goldschmidt doubled in two runs in the fifth inning and Martin Prado drove in Goldschmidt to cap the three-run inning for a 5-3 lead off Los Angeles starter Hyun-Jin Ryu. That was Arizona's last hit until the 12th inning. Goldschmidt leads the NL with 76 RBIs.
Aaron Hill had two hits, including his fourth homer, and scored twice. A.J. Pollock had three hits and scored twice.
Gonzalez hit his 14th home run, a bases-empty shot leading off in the seventh inning, to make it 5-4.
Hill homered off Hyun-Jin Ryu in the first inning and hit a sacrifice fly for a 2-0 lead in the third before the Dodgers scored once in the fourth inning and twice in the fifth off Arizona starter Tyler Skaggs.
Scott Van Slyke hit a sacrifice fly with the bases loaded in the fourth, when the Dodgers left runners on the corners with one out.
Ramirez doubled in two runs after Mark Ellis and Yasiel Puig singled in the fifth to make it 3-2, but reliever Will Harris got Van Slyke to hit into a double play with the bases loaded to end the inning.
NOTES: Dodgers INF/OF Skip Schumaker lost the appeal of his two-game suspension for his part in the June 11 brawl between the Dodgers and the Diamondbacks. He began serving it Wednesday. Schumaker was cited for "aggressive actions." He also will miss the opener of the Dodgers' home series against Colorado that begins Thursday. ... Dodgers RHP Josh Beckett underwent surgery to treat his thoracic outlet syndrome in Dallas on Wednesday. The procedure, performed by Dr. Greg Pearl, included the removal of Beckett's first right rib to alleviate pressure on his nerves. ... With Hill's first-inning homer, the D-backs have an extra-base hit in 75 straight games, the longest streak in the majors this season. ... Arizona LF Cody Ross took a home run away from Dodgers 2B Mark Ellis with a leaping catch at the left field fence in the first inning, and CF A.J. Pollock took at least a double away from Ellis in the third with a diving catch in left-center.