New York Yankees' Starlin Castro connects for a walk-off homer...

New York Yankees' Starlin Castro connects for a walk-off homer to left in the ninth for the Yankees at Yankee Stadium on Wednesday, June 22, 2016. Credit: Joseph D. Sullivan

Chase Headley said “there’s nothing” in baseball that compares to the feeling of hitting a walk-off home run. Starlin Castro, for the first time, experienced it Wednesday afternoon.

The 26-year-old second baseman led off the ninth inning by driving the second pitch he saw deep into the seats in left, leading the Yankees to a 9-8 victory over the Rockies in front of 40,104 at the Stadium.

“To win a game like that in the ninth, it feels awesome,” Castro said. “That’s the first time I’ve hit a homer to win a game.”

Castro took a first-pitch strike from righthander Jason Motte, then sent out the next pitch, a changeup, for his 10th homer.

“I hit it pretty good, I thought it was out right away,” Castro said. “It’s really emotional to get a win like that.”

The Yankees (35-36), who trailed 8-4 going into the bottom of the seventh, are off Thursday before starting a three-game series Friday night against the Twins, baseball’s worst team.

“That was a huge win,” said Headley, whose second-inning grand slam, the Yankees’ first of the season, off Jon Gray gave CC Sabathia a 4-0 lead. “Going into the off day, it would have been tough to lose two in a row to those guys. They were tough on us.”

Sabathia had a rare off day, and he also wrenched his right ankle in the third of his 4 1⁄3 innings. He had been on a major roll coming in, with a 0.82 ERA in his previous seven starts. He allowed six runs (five earned) and seven hits, and his ERA climbed to 2.71 from 2.20. His ankle was wrapped heavily after the game, although X-rays came back negative.

“It’s just a little sore,” said Sabathia, who added that he expected to take his next turn in the rotation.

The Rockies (34-37) swept the Yankees two games last week in Denver before winning, 8-4, Tuesday night. Colorado totaled nine homers in the four games. The Rockies got a three-run shot by Nick Hundley in the fourth, which gave them a 5-4 lead against Sabathia. A two-run shot by Ryan Raburn in the fifth off Anthony Swarzak made it 8-4.

“Obviously,” Joe Girardi said, “a really good comeback.”

It began against Jordan Lyles in the seventh, a four-run inning in which the Yankees sent 10 to the plate. The rally started when Rob Refsnyder reached on a catcher’s interference. After Brett Gardner singled with one out, Carlos Beltran hit his 19th homer, a three-run shot that cut the deficit to 8-7. Brian McCann doubled with two outs off former Yankees lefthander Boone Logan, and Didi Gregorius got McCann in with a single off Miguel Castro, tying it at 8.

“That shows that we never give up,” Gregorius said. “We kept fighting.”

After Swarzak pitched a scoreless sixth, Dellin Betances, Andrew Miller and Aroldis Chapman each threw a scoreless inning. That gave the Yankees a chance to rally against one of baseball’s worst pitching staffs.

The offense, so often the problem this season, came through.

“We needed to stop the bleeding today,” Headley said of the two-game skid. “And we were able to do that.”

More Yankees headlines