Pagan had a single, a double and a triple. Marco Scutaro, Pablo Sandoval and Buster Posey each drove in a run for the Giants, who maintained a 3 1/2 game lead over the second-place Los Angeles Dodgers in the NL West.
Ryan Vogelsong (11-7) went 6 1/3 innings, allowing three runs on four hits with five strikeouts and one walk to get the win after two straight losses.
Javier Lopez was perfect in the ninth in a four-out save, his fourth save of the season.
Ben Sheets (4-4) took the loss, allowing four runs on nine hits and three walks in 4 1/3 innings.
Atlanta has lost six of its last seven.
2014: The Year in Music [PHOTOS]