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.
Ray Liotta sues skin care company over use of likeness
Aaron Carter is still in love with Hilary Duff