The Pirates got a stellar start from Jeff Locke Wednesday afternoon, who bested Adam Wainwright and the St. Louis Cardinals, 3-1, at PNC Park as the stakes continued to climb.

They also got another big swing from Ike Davis, whose two-run homer in the second inning stood as the winning hit. He delivered at three-run homer Tuesday night in the eighth to provide the winning margin.

The Pirates’ timing can’t be understated. By winning consecutive series against the Milwaukee Brewers and the Cardinals, the Pirates improved to 69-64 and inched closer to a wild-card spot after a seven-game losing streak nearly derailed their season.

The Cardinals lead the National League wild-card race by 11⁄2 games over San Francisco, and the Pirates are a game behind for the second wild card, pending the outcome of the Giants’ late game at home Wednesday against the Colorado Rockies.

“We’ve got a lot of grit,” manager Clint Hurdle said. “We don’t have a perfect club. We don’t play perfect. I don’t manage perfect. But we play and we believe in each other and we trust each other. Wherever the game goes, we’re going to go with it. We’re going to keep fighting, scratching clawing … these guys love to play. They flat-out love to play.”

Locke gave up one run, six hits and two walks in 71⁄3 innings. He struck out three and went 2 for 3 at the plate. It was a marked improvement from his previous outing, when he walked a season-high six.

“He got the ball on the ground the whole time he was out there. Twelve groundball outs, got deep in the game. First-pitch strikes set up some things,” Hurdle said.

Locke said the groundball outs made the difference.

“I think the guys were just putting the ball on the ground. Guys were making early outs in the count, and it’s always going to help the starting pitcher, especially when the defense is making the plays they’re making,” Locke said. “Sometimes, you keep the ball down in the zone, round ball, round bat, they just keep the ball down in the zone.”

After Russell Martin was hit by a pitch in the second, Davis clobbered a first-pitch cutter off Wainwright to make it 2-0.