SAN FRANCISCO — It’s becoming increasingly evident that the Rockies’ quest for their first trip to the playoffs since 2009 is not going to come easily.

A painful, 4-3, walk-off loss to San Francisco Tuesday night spelled that out with an exclamation point.

The Giants won the game on Hunter Pence’s bases-loaded sacrifice fly to right field to score pinch-runner Orlando Calixte. Calixte was running for Pablo Sandoval, who opened the ninth with an infield single off reliever Chris Rusin.

With 11 games remaining, the Rockies’ lead for the National League’s second wild card has shrunk to a single game over Milwaukee. The Brewers blanked Pittsburgh 1-0 for their second shutout in a row over the Pirates. Milwaukee won for the ninth time in 11 games.

It was second tough loss in a row for Colorado, which lost 4-3 to San Diego on Sunday at Coors Field. But Carlos Gonzalez does not sense panic in the Rockies’ clubhouse.

“Right now is not the time to sit and complain, or cry about a game you end up losing,” the right fielder said. “You have to keep moving forward and you have to keep your head up.

“We are still in the postseason, if the season finished today. We are still in the driver’s seat. The guys behind us have more pressure than us. They want us to lose. But if we keep pushing hard, eventually we’ll get wins and be rewarded.”

This was a game stuffed full of drama, but the final act left the Rockies’ hearts aching in the City by the Bay.

The Giants’ rally began innocently enough with Sandoval’s slow roller up the third-base line for a hit. Then Ryder Jones put down a sacrifice bunt that found no-man’s land between Rusin and charging third baseman Nolan Arenado. Pinch-hitter Kelby Tomlinson loaded the bases with a single through the hole at second base, setting up Pence’s game-winner.

“I think he was just trying to get a bunt down and he ended up (getting) a single,” Rusin said of Jones’ critical bunt. “He got the ball past Nolan and I did what I could to try to get to it. I threw off-balance and it pulled (second baseman DJ LeMahieu, covering first) off the bag. That’s just baseball.”

Manager Bud Black didn’t think Jones intentionally tried to squeeze the bunt between the mound and third, but it worked out for the Giants nonetheless.

“If you miss that (spot), it’s potential a double play,” Black said. “I mean, Nolan gets it and throws to second and starts a double play.”

The loss washed away some clutch plays by Colorado in the eighth that seemed to foretell a Rockies’ victory.

In the bottom of the frame, with Giants catcher Buster Posey in scoring position, LeMahieu made a diving stop-and-throw on Brandon Crawford’s would-be single up the middle. It seemed, at the time, to be a game-saver.

LeMahieu’s play was an encore to Gerardo Parra’s performance in the top of the inning. The left fielder delivered one of the coolest at-bats of the season, tying the game 3-3. With two outs and Gonzalez perched on third, Parra put together a nine-pitch masterpiece against reliever Hunter Strickland that included six foul balls. Finally, Parra stroked a double to right, scoring Gonzalez and knotting the game 3-3.

“We played well, but we just couldn’t get another key hit,” Black said. “It was a good game and the Giants played well. Somebody has to win it, somebody has to lose it.”

Save for one giant swing by Pence in the fifth, Rockies rookie starter German Marquez did his job, giving his team six innings and surrendering three runs on eight hits. He struck out five and walked just one.

But the fifth inning was Marquez’s undoing. Giants starter Johnny Cueto led off with a single and waltzed home on Pence’s home run to center field, putting the Giants ahead 3-2.

“I just rushed to the plate a little bit and he got ahead in the count and he didn’t miss that 3-1 pitch,” said Marquez, who threw an effective curveball most of the night.

The Giant’s fifth-inning would have been greater had it not been for a perfect strike from Parra in left field.

After Pence’s homer, Denard Span singled and stole second, but he was thrown out trying to score on Brandon Crawford’s two-out single to left. Parra scooped up the ball and threw perfectly to catcher Jonathan Lucroy, who tagged the sliding Span.

Charlie Blackmon’s milestone moment gave the Rockies a 2-0 lead in the second. The MVP candidate’s two-out double to center not only scored Trevor Story and Ian Desmond, it also was Blackmon’s 200th hit of the season. He became the eighth different Rockies player to reach the 200-hit mark, and the first since Matt Holliday had 216 in 2007.

San Francisco cut the lead to 2-1 in the fourth on an RBI single to left by Sandoval. He drove in Posey, who led off with an infield single to short that Story almost turned into a dive-and-throw diamond gem.

Missed opportunities and double plays haunted the Rockies early against Cueto. In the first, with two on, Cueto struck out Nolan Arenado and Parra. LeMahieu hit into a double play in the fifth, Story did the same in the sixth and Lucroy followed suit in the seventh.

The Rockies will attempt to split the two-game series on Wednesday afternoon before heading to San Diego on Thursday to begin a four-game series.