A victory for the Dodgers would have given them the National League West crown, but the outcome left their magic number for clinching the title at two.
Stephen Fife (4-4) was given a spot start by the Dodgers in their bid to become the first team in the majors this year to wrap up a division championship, but he gave up four runs in two-plus innings.
The Diamondbacks boosted their lead to 4-0 in the third with Gerardo Parra driving in a run on a fielder's choice grounder and later scoring on a bases-loaded walk.
Arizona's lead was only 4-3 heading into the eighth, but the Diamondbacks piled on five in that inning with Adam Eaton's two-run double finishing the scoring.
The win went to Brandon McCarthy (5-9), who allowed three runs on 10 hits in six innings.
Los Angeles, which has dominated its division since late June, lost for the fifth time in six games. The Dodgers will have another chance to clinch the NL West on Thursday when they again take on the Diamondbacks.
Swim Week Miami Beach 2014 [PHOTOS]