Crawford turned on the second pitch thrown by Rex Brothers (1-1) and drove it into McCovey Cove for his first career walkoff homer and first splash homer.
Sergio Romo (1-0) pitched a scoreless 10th for the win.
The Giants nearly won it in the ninth, when Gregor Blanco hit a drive off the wall in right field with two outs and nobody on. When Michael Cuddyer misplayed the carom off the wall, Blanco tried to score on the play but was narrowly thrown out on a relay from second baseman D.J. LeMahieu to Rosario.
The play was eerily similar to one last year when Pagan shocked the Rockies with a game-ending, two-run, inside-the-park homer in the 10th inning of a 6-5 win May 25.
Tim Hudson appeared to be cruising to this third straight win to open his San Francisco career, taking a 4-2 lead into the eighth inning having thrown only 77 pitches. The only damage came on solo homers by Rosario and Morneau.
Hudson allowed four runs and five hits in 7 1-3 innings. He hasn't walked a batter in 23 innings, setting a San Francisco record for most consecutive innings without a walk to open the season.
The Giants had given Hudson the lead when they broke a 17-inning scoreless streak by scoring three runs in the fifth inning against Tyler Chatwood.
Chatwood came off the disabled list from a hamstring injury to make his season debut and started strong, facing just one batter over the minimum through four innings.
But he ran into trouble after hitting Hunter Pence with a pitch to lead off the fifth. Pence later scored on a sacrifice fly by Crawford.
Pagan then added a two-run single with two outs in the inning to make it 3-1. All 10 of Pagan's RBIs this season have come with two outs.
Sandoval added a leadoff homer in the sixth, his second of the year.
NOTES: Atlee Hammaker opened the 1983 season with 21 straight innings without a walk for the Giants. ... Rosario threw out Brandon Hicks trying to steal second in the seventh inning, Colorado's first caught stealing in eight attempts this season. ... The Rockies optioned INF Charlie Culberson to Triple-A Colorado Springs to make room for Chatwood. ... The Giants open a three-game home series against the Los Angeles Dodgers on Tuesday with Tim Lincecum (0-1) taking on Josh Beckett (0-0). ... The Rockies open a four-game series in San Diego on Monday with Jordan Lyles (2-0) taking on Eric Stults (0-2).