DENVER — One minute they were howling, mimicking Santiago Casilla’s wild warm-up swings and yelling at the relief pitcher not to get hurt. The next minute, the Giants were wondering what else could go wrong.

Casilla injured his right hamstring running out a grounder to short in the ninth inning of a 5-1 win over the Colorado Rockies. Five innings earlier, starter Matt Cain also had departed with a right hamstring injury. Both players are scheduled for MRIs, and manager Bruce Bochy spent the late hours Wednesday tucked into his office at Coors Field, discussing roster moves with general manager Brian Sabean. The Giants won’t know the severity of either injury until Thursday, but Casilla told teammates he was headed for the disabled list and Cain was unsure if he would be able to avoid the D.L. for the second time in two months.

The injuries left teammates stunned on a night that should have been a celebration. The Giants held the most explosive offense in the majors to five hits and hit three soaring homers. But the handshake line was somber, the clubhouse victory music low-key.

“They’re both big blows,” right fielder Hunter Pence said. “It’s just a tough day.”

Brandon Crawford, who like Pence hit a solo homer, said the dugout mood shifted as soon as Casilla sprinted across the bag, sprawled onto the grass and started pounding the ground in pain. The valuable reliever was helped off the field by two trainers, not putting weight on his injured right leg.

“Everyone was laughing and joking, and we were still laughing when he hit the ball,” Crawford said. “And then he’s on the ground in pain. It was a bittersweet win, for sure. It’s one of the most depressing feelings we’ve had in a win.”

Cain threw three hitless innings before feeling something in his hamstring on his final pitch of the third. He was replaced by Yusmeiro Petit, who made an emergency start April 29 when Cain cut his hand while preparing a ham and cheese sandwich. As he did that night, Petit was sharp, throwing three shutout innings against a Rockies lineup that leads the league in runs. The Giants are hopeful the aftermath this time around brings better news. Cain’s trip to the disabled list after the sandwich incident was just the second of his career. He’s aiming to avoid a third.

“We’ll get it checked and see from there,” Cain said. “Today the adrenaline was still going, but we’ll see how it reacts (Thursday morning).”

The Giants already are without first baseman Brandon Belt (broken left thumb) and played a second straight game without catcher Buster Posey (nerve irritation in lower back). Angel Pagan returned to the lineup after missing two games with a shoulder sprain, but it was the heart of the order that put the Giants in gear.

Pence hit his fourth homer of the season in the fourth and Pablo Sandoval followed two innings later with his fourth blast. Consecutive doubles from Michael Morse and Hector Sanchez made it 3-0 and Crawford hit a monstrous solo shot in the seventh, reaching the second deck in right field.

Crawford was in the middle of a game-changing play in the eighth inning. The Rockies had loaded the bases with no outs, but Casilla entered and got Michael Cuddyer to hit a sharp grounder up the middle. Crawford snagged it but his momentum carried him toward right field. He glove-flipped the ball to second baseman Brandon Hicks, who made a barehanded catch, stomped second and threw to first for a crucial double play. Casilla got a fly out to end the inning and keep the lead at four.

The right-hander has just five career plate appearances but they may be the most entertaining in baseball. In 2011, Casilla drew a four-pitch walk against the Marlins while standing so far from the plate that his left foot was out of the batter’s box. In early 2012 he took wild, spinning cuts while striking out against the Brewers. Later that year he singled against the Diamondbacks, showed off an exaggerated, arm-pumping sprint to first and joked he hits “the other way, like Posey.”

With a short bench and a four-run lead, Casilla was sent to hit with two outs in the ninth. His teammates had visions of another moment that would be trending on Twitter, but Bochy told Casilla not to swing. The Giants already had lost David Huff to a quad injury when he beat out an infield single at Coors Field earlier this season. On a 3-2 count, Casilla hit a grounder to short and busted it down the line. He thought he had a hit.

An hour later he was hobbling out of the clubhouse with trainer Dave Groeschner, still barely able to put weight on his leg.

“It was shocking he would run like that,” Bochy said. “I don’t know what got into him.”

For more on the Giants, see Alex Pavlovic’s Giants Extra blog at blogs.mercurynews.com/Giants. Follow him on Twitter at twitter.com/AlexPavlovic.