ST. LOUIS — Matt Carpenter is feeling better and it showed Saturday night.

Carpenter and Yadier Molina homered, and the St. Louis Cardinals beat the Pittsburgh Pirates 4-3 to gain ground in the NL Central.

St. Louis pulled within three games of division-leading Chicago with its sixth victory in seven games.

“We’re going through a special stretch right now,” Carpenter said. “It feels like a special year. It feels like a lot of previous years that we’ve had some really fun Septembers here and anytime you have a chance to play for something at this point in the season you’ve just got to be happy with that.”

Tyler Lyons (4-0) pitched a scoreless inning for the win, and Juan Nicasio got three outs for his second save since he was acquired in a trade with Philadelphia on Wednesday.

Playing in just his second game after leaving Monday’s 2-0 win at San Diego with right shoulder bursitis, Carpenter hit a tying solo drive in the seventh for his 19th homer.

“Definitely feels better,” Carpenter said. “It’s just something that I don’t think I’ll completely be able to get past until this season’s up and I get a chance to rest and rehab it. It doesn’t matter how I felt, because we’re going to find a way to do this.”

Paul DeJong hit a leadoff double in the eighth and advanced on a groundout before coming home on Randal Grichuk’s bouncer to third, making it 4-3 St. Louis.

“It was contact play, it was down and luckily scooted away from him a couple feet and that gave me enough time to score,” DeJong said. “He did a good job of knocking me in.”

Chad Kuhl pitched six effective innings for Pittsburgh, which has dropped four in a row. Kuhl also helped himself with an RBI double in the second.

The Pirates grabbed a 3-2 lead on Adam Frazier’s inside-the-park homer in the seventh . Cardinals center fielder Dexter Fowler got hurt crashing into the wall going after Frazier’s drive, and the second baseman scored without a throw.

“Off the bat I thought it was either gone or caught,” Frazier said. “Fowler’s a pretty good outfielder there. It just got over his glove I guess and I didn’t see anybody around and him lying there so I took off.”

It was the first inside-the-park homer for the Pirates since Andrew McCutchen accomplished the feat on Sept. 10, 2014. It was the first in Busch Stadium since Edwin Encarnacion for the Cincinnati Reds on Aug. 31, 2007.

Fowler departed with a left knee contusion and was replaced by Grichuk.

“Any time you see a teammate look like he seriously hurts himself you hate to see that,” Carpenter said. “It ended up being a big run, but you care more about your teammate than the run at the time. Thankfully we were able to come back and win the game.”

Cardinals manager Mike Matheny said Fowler will get an MRI on Sunday. X-rays came back negative.

“We’ll know a little bit more tomorrow but so far everything we’ve seen looks pretty good,” Matheny said.

St. Louis almost wasted a solid start for Carlos Martinez, who allowed two runs and four hits in six innings. The All-Star right-hander struck out Kuhl looking in the sixth to reach 200 strikeouts in a season for the first time. His previous high was 184 in 2015.

The Cardinals trailed 2-0 before Molina connected for a two-run shot in the second. It was just the 97th home run given up by the Pirates starters, second-lowest in the majors.

Kuhl gave up just two hits, both to Molina, but walked five. Only one of the two runs he allowed was earned. George Kontos (0-6) took the loss.

TRAINING ROOM

Pirates: C Francisco Cervelli (left quadriceps irritation) threw and hit and is expected to start running on Monday.

Cardinals: RHP Adam Wainwright (right elbow) began throwing from flat ground.

UP NEXT

Pirates: RHP Ivan Nova (11-12, 4.11 ERA) is two innings away from setting a career high for innings pitched in a season, which is 170 1/3 in 2012. He is 1-1 with a 3.29 ERA in two career starts against St. Louis.

Cardinals: RHP Michael Wacha (11-7, 4.21 ERA) has won his last two starts, going six innings and earning a quality start in each. He is 4-3 with a 4.39 ERA in 13 career games against Pittsburgh.