With every misstep, the improbable road back to Rocktober gets a bit steeper.

Colorado had another such setback Tuesday night, when the San Francisco Giants negated the Rockies’ ninth-inning rally at Coors Field to win the game 8-4 and take the series, too.

After Colorado tied it up in the ninth inning with Ian Desmond’s two-run homer off San Francisco closer Will Smith, the Giants struck right back the next frame. Rockies closer Wade Davis let in three runs and was yanked for Bryan Shaw, and the Giants scored another run as a rare error by Nolan Arenado made the damage even greater.

“That was a great, spirited comeback against one of the best closers in the game,” Rockies manager Bud Black said. “The momentum was on our side … But it goes to show when you play a game, it takes so many different guys to contribute (to win). It just didn’t happen for us in the 10th.”

Of Davis specifically, who walked two and allowed two hits while recording one out, Black said: “He couldn’t find the strike zone when he needed to throw a strike.”

The late-inning dramatics followed a dominant start by San Francisco southpaw Drew Pomeranz while the Rockies wasted the best home outing of Peter Lambert’s young career. The rookie right-hander turned in a quality start with six innings of two-run ball on six hits, three strikeouts, and no walks.

“I was pretty comfortable out there,” Lambert said. “Especially after the last few days, my biggest goal was to get deep into this game to save our bullpen a little bit.”

The setback marked Colorado’s 10th loss in its last dozen games.

“Every day’s a test, and when you get into this time of the season, that test intensifies,” Black said. “I think we’re going to come out of this and play better baseball, but the last few weeks it hasn’t been as consistent as we need to play.”

Lambert’s lone trouble came in the second inning. Outfielder Alex Dickerson, en route to a career-high four-hit night, led off with a single, after which Mike Yastrzemski doubled him home. Then, with two outs, Joe Panik’s RBI single that deflected off Lambert made it 2-0 San Francisco.

“(Lambert’s) fastball command was solid, and the use of the changeup, curveball, and slider was effective,” Black said. “The one pitch he’d like to have back would probably be the pitch to Yastrzemski that was up over the plate. But tonight was very encouraging.”

Meanwhile, Pomeranz — who pitched for the Rockies from 2011-13 and entered the night with a 4.35 ERA over 20 appearances, and 16 starts, at Coors Field — was on cruise control. The southpaw tossed five innings of one-run ball, with three hits and four strikeouts as the Rockies struggled to string together quality at-bats.

Colorado’s only mark against Pomeranz came in the sixth inning, when Garrett Hampson’s leadoff walk and Charlie Blackmon’s subsequent single chased the 30-year-old veteran from the game. Trevor Gott spelled Pomeranz, and Colorado used Trevor Story’s fielder’s-choice grounder to score Hampson and get on the board, cutting the deficit to 2-1.

Jake McGee took over for Lambert in the seventh inning, getting two outs before Jairo Diaz closed the door on the inning with a strikeout of Tyler Austin. Scott Oberg was nicked for a run in the eighth via Dickerson’s RBI single.

Colorado’s Chad Bettis was then taken deep by Yastrzemski in the ninth inning, extending the Giants’ lead to 4-1.

Colorado looks to avoid the sweep in Wednesday’s matinee.

“There’s a lot of positives and things to build on,” Desmond said. “We need to keep on grinding; we’ve been grinding all year, and that paid off early in the season for us when we ran into a nice stretch of comeback wins. We used that adversity to build on, and we’ll do the same with this stretch.”