ST. LOUIS — Kolten Wong hit a leadoff home run in the bottom of the ninth inning and the resilient St. Louis Cardinals beat the San Francisco Giants 5-4 on Sunday night, evening the National League Championship Series at one game apiece.

The Cardinals won after losing All-Star catcher Yadier Molina to a strained oblique muscle in the sixth. Molina was getting further tests, and manager Mike Matheny said it “didn’t look real good.”

“We just knew we had to keep grinding,” Wong said. “When you lose someone like Yadi, it’s definitely tough for us, but we told ourselves we’ve been going through this all year.”

In a back-and-forth game, St. Louis got homers from rookie pinch-hitter Oscar Taveras in the seventh and Matt Adams in the eighth to take a 4-3 lead.

It was a rare postseason failure for the reliable San Francisco bullpen, which allowed a home run in each of the final three innings.

“They are the reason we’re in this situation, and you give (the Cardinals) credit,” manager Bruce Bochy said. “They threw out some good at-bats and we made a couple of mistakes and they took advantage of them.”

The Giants tied it when pinch-runner Matt Duffy dashed home from second base on a two-out wild pitch in the ninth. San Francisco wound up losing for just the second time in its past 14 postseason games.

The best-of-seven series resumes Tuesday night with Game 3 in San Francisco with John Lackey going for St. Louis and Tim Hudson starting for the Giants.

Wong hit an 0-1 pitch from Sergio Romo for his second big homer this postseason. The rookie’s seventh-inning drive was the decisive blow in Game 3 of the NL Division Series against the Dodgers.

St. Louis, last in the NL with 105 home runs during the regular season, has hit 11 homers in six playoff games — seven in the seventh inning or later. Earlier, Matt Carpenter connected for the fourth time this postseason.

Seth Maness retired Pablo Sandoval on a comebacker with the bases loaded to end the top of the ninth to get the win.

Maness came on after closer Trevor Rosenthal couldn’t hold a one-run lead. Rosenthal’s pitch bounced off the glove off backup catcher Tony Cruz and Duffy, running on a full count, never broke stride and slid home with the tying run.

Molina bent over in pain after a swing and didn’t make it out of the batter’s box on a double-play ball in the sixth. Wincing, he gingerly walked off the field.