DENVER -- A home run shy of the cycle, Nolan Arenado wasn't thnking about personal accomplishments when he came to bat in the ninth inning Sunday.
"Honestly, I was just trying to get the ball to the outfield," Arenado said. "I'm not going to let my ego get in the way here. We got to win the ballgame."
The Rockies did that in stunning fashion when Arenado hit a first-pitch, three-run homer to win 7-5 and sweep a four-game series from the Giants for the first time.
Arenado is the eighth player in Rockies history to hit for the cycle and first since Michael Cuddyer on Aug. 17, 2014, against Cincinnati. Arenado is the 31st player in major league history to hit a walk-off homer to complete the cycle and first since teammate Carlos Gonzalez did it July 31, 2010, against the Chicago Cubs.
It was the first cycle for Arenado, who tripled in the first, singled in the fourth and doubled in the sixth before hitting his 15th home run. It was his first homer since June 3 and first at Coors Field since May 14.
"I back-spinned it," Arenado said. "That's my whole goal is to backspin the baseball. Thank God it went out. I was a little nervous, because I saw (left fielder Austin Slater) go back and I hadn't hit a homer in awhile."
The Giants had scored three runs in the ninth to take a 5-3 lead against Jake McGee, who was pitching because closer Greg Holland was unavailable.
Hunter Pence hit a two-run homer, No. 211 in his career and his first as a pinch hitter, and Brandon Crawford, whose two-run homer gave the Giants a 2-0 lead in the fifth, doubled home a run before Carlos Estevez (4-0), recalled Sunday from Triple-A Albuquerque, struck out Buster Posey to end the inning.
Melancon, who signed a four-year, $62 million contract with the Giants as a free agent in December, retired pinch-hitter Tony Wolters on a ground out to open the inning. But Raimel Tapia singled, as did Charlie Blackmon, sending Tapia to third. DJ LeMahieu drove in Tapia with a single, putting runners on the corners for Arenado.
Arenado said the sell-out crowd of 48,341 at Coors Field was "the loudest I've ever heard in this place." Before he drove Melancon's first-pitch cutter into the left-field stands, Arenado had a moment of reflection.
"I just literally said like a little prayer," Arenado said. 'I was like, 'Calm down. Give me the strength to slow this game down.' I want to be up in that situation. I feel confident. I'm not afraid in those situations. You fail a lot in this game, and I just wanted that last at-bat. Thank God it worked out."
The win was the fifth straight and 12th in 15 games for the Rockies (46-26), who remained one game ahead of Arizona and Los Angeles in the National League West. The Rockies are 10-1 against the Giants this season and have beaten them nine straight times, a franchise-record winning streak against any NL West opponent.
The Giants (26-45) have lost six straight and 15 of their past 19 games to fall a season-high 19 games below .500.
Melancon pitched for the first time in 10 days but said the layoff had no effect.
"They were making contact," said Melancon (1-2), who has a 5.09 ERA in 19 games. "I don't think it was good contact. Arenado's was, obviously. I wanted to surprise him in and go from there. I was hoping to get a ground ball to short. My performance has been absolutely terrible. Yeah. I need to be better."
Giants starter Ty Blach, a Denver native, pitched 6 2/3 innings in his first start at Coors Field, where he made his major league debut in September. He gave up a run in the sixth when LeMahieu drew a leadoff walk and Arenado followed with a double.
The Rockies went ahead 3-2 in the sixth when Trevor Story hit his 10th homer, and Pat Valaika hit his first career pinch-hit homer and his fifth of the season. He's 7-for-21 with four RBIs as a pinch hitter.
After putting their leadoff batter on base without scoring in the first four innings, San Francisco finally broke through against Tyler Chatwood in the fifth when Denard Span walked for the third straight time and Crawford hit an opposite-field home run down the left-field line with two outs.
The homer gave the Giants a 2-0 lead. And they pulled ahead 5-3 in the ninth before Arenado's blast resulted in a disheartening defeat. San Francisco lost two games by two runs and another by one in this series.
"It's a shame, the way they're fighting here, and they couldn't come away with a win," Giants manager Bruce Bochy said. "This, really, was as tough a one as we've had."
NOTES: Rockies RHP Carlos Estevez was recalled from Triple-A Albuquerque and struck out the one batter he faced in the ninth. ... Rockies RHP Chad Qualls (lower back spasms) was placed on the 10-day disabled list retroactive to Friday...Rockies RHP Chad Bettis (cancer) threw 15 fastballs in his first bullpen session from 60 feet, 6 inches...Rockies OF Gerardo Parra (strained right quadriceps) ran outside at about half speed for the first time since he was injured June 6...Giants outfielder Jarrett Parker (broken right clavicle) will begin a rehab assignment Monday with Triple-A Sacramento...Giants LHP Madison Bumgarner (bruised ribs, sprained left shoulder) is scheduled to throw a second simulated game Wednesday at the Giants' complex in Scottsdale, Ariz.