SAN FRANCISCO -- Brandon Crawford's first splash hit came at a most opportune time.
"It feels good," he said. "I wanted to hit one in there for a long time. I'm glad I finally got to."
Crawford turned on the second pitch thrown by Rex Brothers (1-1) and drove it into the water on the fly for his first career walkoff homer and first splash homer.
"He smoked that one," manager Bruce Bochy said. "I asked him if he ever hit one further."
The homer also helped Crawford show Bochy that he deserves more at-bats against left-handed pitchers. Bochy said earlier this season that Crawford might sit against certain lefties after hitting just .199 off them last season.
But he is 7 for 14 so far this year against lefties with no bigger hit than the one against Brothers.
"That's what you want these guys to do is take anything that you may throw at them that may not have them in the game as a challenge," Bochy said. "To his credit, he's done that."
Sergio Romo (1-0) pitched a scoreless 10th for the win.
But the Rockies got bad news after the game when they learned lefty Brett Anderson broke the index finger on his throwing hand Saturday and is expected to miss four to six weeks.
"We have to play the hand we're dealt with here," manager Walt Weiss said. "His arm is great and so is everything else. It's better than having arm trouble."
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 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.
"I saw it develop and thought this can't happen to you two years in a row," Weiss said. "But Cuddy kept his cool, gave D.J. a good throw and then D.J. then made good throw to home."
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.
"I would have been sick if we had lost this game because I felt like I had a pretty good game and then in the eighth inning we were tied up," Hudson said.
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 with a sacrifice fly by Crawford and two-run single from Pagan.
Sandoval added a leadoff homer in the sixth.
Atlee Hammaker opened the 1983 season with 21 straight innings without a walk for the Giants. ... The Giants open a three-game home series Tuesday against the Dodgers with Tim Lincecum (0-1) facing 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).