The Rockies scored three times in both the second and third innings with all the runs coming on homers by Todd Helton, Nolan Arenado and Wilin Rosario.
San Francisco got back in the game with a five-run fourth that featured a three-run double by Brandon Crawford and then took the lead in the sixth.
Hunter Pence and Brandon Belt singled to start the sixth off Jhoulys Chacin (3-3) and Gregor Blanco delivered the tying run with a sacrifice fly. Pagan's two-run single came off Adam Ottavino with two out.
San Francisco snapped a two-game skid.
Wisconsin business offering 'therapeutic cuddling' forced to close
'SNL': 'Anchorman 2' cast, One Direction sing 'Afternoon Delight' [VIDEO]