The Giants began the crucial series a half game behind the Dodgers and emerged with a 2 1/2-game advantage nearing the final month of the regular season.
Arias came into the game with two home runs and 21 RBI in 246 at-bats this season, but erupted with a big night that included three of the Giants' eight hits.
Pablo Sandoval's sacrifice fly delivered Pagan with the first run of the game and Arias then hit a two-out homer to right to make it 3-0.
Arias doubled home another score during a three-run sixth and he added a two-run double in the seventh.
Matt Cain (13-5) allowed a run on seven hits with five strikeouts over seven innings to get the win. It was Cain's third win in as many starts after he had failed to pick up a victory in six straight appearances.
The Dodgers scored three runs in the eighth on an RBI double by Matt Kemp and a two-run single by Luis Cruz.
Celebrity Breakups and divorces of 2014 [PHOTOS]