Ramirez and Ellis also had back-to-back two-out singles in the ninth to force extra innings. That put the Dodgers in position to sweep the three-game series with NL West-leading Arizona with their 15th win in 18 games.
Los Angeles is back to .500 on the season and 1 1/2 games back of the Diamondbacks.
Josh Collmenter (4-2) relieved Bell and allowed one hit over four innings until Ramirez hit the first pitch of the 14th inning for his eight home run. Ellis followed with his fourth homer.
Ramirez and Ellis were both 3-for-6 with Ramirez driving in three runs and scoring twice. Ellis had two RBI and a run scored.
Kenley Jansen (3-3) picked up the win, allowing one hit over two innings. The Dodgers' bullpen was sharp, with six pitchers combining for nine innings of two-hit, shutout relief.
Arizona twice led by two runs, the last time when Paul Goldsmith doubled in two runs and scored on Martin Prado's single for a 5-3 lead in the fifth.
Aaron Hill drove in the first two Diamondback runs with a first-inning home run and a third-inning sacrifice fly. Ramirez scored for the Dodgers on Scott Van Slyke's sacrifice fly in the fourth and Ramirez doubled in Mark Ellis and Yasiel Puig to tie the score in the fifth.
After Goldsmith restored the two-run Arizona lead, Gonzalez hit a home run for Los Angeles in the seventh.
Celebrity Breakups and divorces of 2014 [PHOTOS]