Ellis tied the game with a two-out, run-scoring single in the ninth inning off Heath Bell and Ramirez hit the first pitch of the 14th off Collmenter (4-2) just over the wall in right field. Five pitches later, Ellis made it 7-5 with his fourth homer.

Kenley Jansen (3-3) pitched the final two innings for the Dodgers, who used all of their position players and had Zack Greinke, Monday's starter, pinch hit in the 10th inning.

Los Angeles has won 15 of 18 to move within 1 1-2 games of the NL West lead after its first sweep of Arizona since 2010.

Arizona went through eight pitchers in the 19th game in the majors to go at least 14 innings this season, according to STATS. There were 20 total last season.

Aaron Hill homered and drove in two runs, and Paul Goldschmidt hit a two-run double for the Diamondbacks, who went seven innings -- until two outs in the 12th -- without a hit.

Adrian Gonzalez led off the seventh inning with a solo homer to cut Arizona's lead to 5-4, then worked a two-out walk off Bell in the ninth. Ramirez followed with a single and Ellis tied the game with a run-scoring single on Bell's fifth blown save -- 19th by the Diamondbacks.

The more than five-hour game started with the teams trading leads.

Tyler Skaggs had a superb return to Arizona's rotation on Friday, allowing three hits and striking out five in eight scoreless innings against Colorado after being called up from Triple-A Reno. The left-hander wasn't nearly as good against the Dodgers, giving up a run on Scott Van Slyke's sacrifice fly in the fourth inning and a two-run double to Ramirez that put the Dodgers up 3-2 in the fifth. Skaggs then walked two to load the bases, but reliever Will Harris prevented any further damage by getting Van Slyke to hit into an inning-ending double play.