"You hit one, you're lucky," Martinez said of Gant's second blast of the season. "You hit a second one, you're a power hitter."
The Cardinals have won 17 of 21 and took their tenth consecutive series, their longest series winning streak since 2009, when they also won ten in a row.
"It's an important thing," Cardinals manager Mike Shildt said. "We want to get better as the game goes and we want to get better as the series goes. And if you take care of the series, the rest of it just falls into place."
Gant (6-5) pitched out of a bases-loaded situation in the first and a two-on, no-out jam in the third to win for the third time in his last four tries. He struck out six in 5 2/3 innings and has allowed one earned run in his last 12 2/3 innings.
"It was a great team win, a great series win," Gant said. "Another series win, and we're going to try to keep on chugging."
Pirates starter Joe Musgrove (5-8) opened the game with 21 consecutive strikes, a first in the majors since pitch tracking began in 1988, according to Stats. That control didn't do him much good, though. He gave up five runs in six innings.
"I came out sharp but I didn't keep my foot on the gas," Musgrove said. "I didn't keep going. That's got to be done against a good lineup like that."
Musgrove's strike streak ended with a first-pitch ball to Bader in the third, and two pitches later, Bader went deep to left. Gant then homered on a 2-1 pitch, giving St. Louis consecutive home runs for the seventh time this season.
"I'm just trying to make contact and contact was made tonight," Gant said.
Gant tied Miles Mikolas for most home runs among St. Louis pitchers this season. After starting his career 0 for 30, Gant has homered twice in his last six at-bats. He is the third pitcher in the expansion era to have his first two career hits as home runs.
Shildt said Gant put in a gutty performance.
"He was making pitches," Shildt said. "He missed a few spots and the guys made some plays, but John's a really good competitor, he's a mentally tough guy, so he was really just able to compete with what he had and used all his pitches."
Martinez singled and scored in the fourth and drove in two more with a single in the fifth to give the Cardinals a 5-0 lead. Martinez has hit safely in 20 of 25 games in August and has a team-high 18 multi-RBI games.
"He was actually trying to mix in some pitches and he was throwing some different pitches than we were expecting," Martinez said of Musgrove. "We just had to make the adjustments."
Pittsburgh lost for the seventh time in its last nine games. The Pirates stranded 12 runners and went 0 for 9 with runners in scoring position.
"There was hard contact," Pirates manager Clint Hurdle said. "It's not fair. There's times when it's not fair. You hit hard balls, you hit them right at people but you've just got to play man."
FACE IN THE CROWD
St. Louis Blues star Vladimir Tarasenko signed autographs on the field before the game.
Cardinals: OF Marcell Ozuna (right shoulder inflammation) took batting practice Thursday and is on track to return from the 10-day disabled list when eligible on Sept. 1.
Pirates: RHP Jameson Taillon (10-9, 3.49 ERA) kicks off a three-game series on the road against the Atlanta Braves and RHP Anibal Sanchez (6-5, 3.05 ERA). Taillon has allowed three earned runs or fewer in his last 16 starts.
Cardinals: LHP Austin Gomber (4-0, 2.79 ERA) will open a three-game home series Friday night against the Cincinnati Reds and RHP Homer Bailey (1-12, 6.17 ERA). The Cardinals are 6-0 when Gomber starts.
More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports
NL East Stock Watch: Which team is having the best winter?
The division's four contenders have made the biggest moves to restock their rosters, but they're far from finished.
Schefter: Murray will go in 1st round
Adam Schefter joins SportsCenter to analyze Kyler Murray's decision to declare for the NFL draft.
Kyler Murray declares for 2019 NFL draft: Answering questions about what's next
Murray has declared for the NFL draft. Can he still play baseball? What are the key dates to pay attention to? Here's what you need to know.
Kyler Murray enters name in NFL draft, but A's can still negotiate with Heisman Trophy winner
Heisman Trophy winner Kyler Murray has announced he will enter the NFL draft, but the Sooners quarterback can still weigh his baseball options.
Derek Holland re-signs with Giants on one-year deal
Derek Holland, who made 30 starts with the Giants last season, re-signed with San Francisco on a one-year deal, the team announced.
Why next 30 days will be busiest of MLB offseason
Spring training is only a month away, and history tells us free agents don't perform as well if they miss time in camp.