The Giants had erased a 5-3 Cubs lead in the sixth when Brandon Belt socked an RBI triple and then scored on a wild pitch by Chicago's Manny Corpas.
Then, facing Carlos Marmol (2-3) in the ninth, Xavier Nady drew a lead-off walk, with Gregor Blanco coming in to pinch-run. Blanco stole second as Belt struck out and Brandon Crawford drew another base-on-balls, putting two runners aboard.
That brought up Pagan, who lined a solid hit to center field as Blanco slid home with the go-ahead run.
Scutaro capped with the rally with another hit to score Crawford and the National League West-leading Giants claimed the rubber match of a three-game series.
Alfonso Soriano belted a three-run homer for the Cubs.
Jessica Simpson shares three-way kiss with friends in photo
Dennis Rodman pledges to end trips to North Korea