DENVER — Carlos Martinez labored most of the game. Not with his pitches, but catching his breath.

Martinez threw five effective innings despite struggling to take a deep breath in the thin air and added a two-run double, helping the St. Louis Cardinals gain ground in the NL playoff race with a 5-3 win over the Colorado Rockies on Monday night.

The Cardinals moved into a tie for the second wild card with the Giants, who blew a ninth-inning lead in Los Angeles and lost 2-1 to the Dodgers.

St. Louis and San Francisco are one game behind the New York Mets, who lost to Atlanta.

Martinez, who turns 25 on Wednesday, gave himself an early birthday present by holding Colorado to two runs while striking out six. The right-hander is 9-1 on the road this season.

Martinez (15-8) helped his own cause with a two-out double as part of a three-run fourth. He also was hit just below the left leg by a fastball from Tyler Anderson (5-6) in the third — two pitches after Randal Grichuk lined a two-run homer.

Really, though, the biggest issue for Martinez was breathing in the Mile High City.

“The altitude affects everybody a little differently,” Cardinals manager Mike Matheny said. “It affected him today, for sure.”

Martinez was cruising along until one out in the fourth, when Matheny came out to check on him. Martinez was quite winded, and a ball boy brought out a cup of water, which he quickly chugged and continued on his way.

“I tried to take deep breaths and stay focused,” Martinez said through a translator. “It didn’t take away my focus in the game.”

Martinez was pulled after the fifth because of an elevated pitch count. The bullpen bottled up the Rockies until pinch-hitter Ryan Raburn hit a solo homer off Kevin Siegrist in the ninth to make it 5-3.

After allowing a single to Charlie Blackmon, Siegrist struck out DJ LeMahieu before walking Carlos Gonzalez. The left-hander got Nolan Arenado to line out to left field for his third save.

Anderson allowed five runs — two earned — in seven solid innings. The rookie is 5-2 with a 3.00 ERA in 12 starts at Coors Field.

“He ended up getting through seven, so it was a good outing,” Rockies manager Walt Weiss said.

Arenado, a Gold Glove third baseman, made a costly throwing error in the fourth. Martinez followed with a two-run double — giving him six RBIs this season — and Matt Carpenter added a run-scoring single.

“We have seen (Arenado) make that play. He makes it look easy and that wasn’t an easy play,” Weiss said. “And then the throw was a little high. It was a tough play.”

LeMahieu finished 2 for 4 to raise his average to .349 and take a slight lead over Washington’s Daniel Murphy in the NL batting race. Murphy is hitting .348.

TRAINER’S ROOM

Cardinals: Matheny said there’s been no discussion of possibly activating OF Matt Holliday (broken right thumb) to serve as a pinch runner. Holliday is still dealing with some swelling issues in the thumb after batting practice sessions.

Rockies: There are no plans for surgery on the broken left hand of 1B Mark Reynolds after he was hit by a pitch Sunday, ending his season. “It’s a tough break for Mark,” Weiss said.

HOLD THE ONIONS

A launched baseball in batting practice left a burger joint in quite a pickle.

The Helton Burger Shack located behind the bleachers in left field was closed Monday after a ball broke the glass protecting the prep area.

No official word on whose liner actually broke the window pane — Twitter conversations credited Holliday — but it wasn’t the restaurant’s namesake; Todd Helton retired after the 2013 season.

BAD BLOOD?

The Rockies have some history with Martinez. In July 2015, things got a little heated after he hit LeMahieu with a pitch.

Martinez didn’t think there was any purpose to the pitch that plunked him Monday night, even though it did sting.

“I don’t think it was any retaliation. That happened last year. It’s a new year,” Martinez said. “I wouldn’t like to think that. I think it just got away.”

Anderson downplayed it, too.

“It was a ball that cut and hit him in the shin,” he explained.

UP NEXT

Cardinals: With 132 wins, RHP Adam Wainwright (11-9, 4.51 ERA) tries to move closer to tying Dizzy Dean (134) for sixth on the team’s career list.

Rockies: LHP Jorge De La Rosa (8-8, 5.22) is 4-0 with a 4.01 ERA in four starts against St. Louis at Coors Field.