McGwire, who also flied out, struck out and singled, leads the majors with 130 walks including eight in his last three games and needs a walk per game in the final 41 games to break Babe Ruth's record of 170, set in 1923.
"He might break it by September 1," manager Tony La Russa said. "It's ridiculous."
McGwire had gone nine straight plate appearances without putting the ball in play after walking on a 3-2 count in the first. He ended that string with a flyout in the third, then walked in the fifth and sixth.
Pirates manager Gene Lamont didn't think his pitchers were ducking McGwire because Brian Jordan, who bats fourth, also is a dangerous hitter.
"I'm sure the pitchers are leery of him," Lamont said. "The bottom line is we're just trying to win the game. We don't care if Mark hits three home runs, as long as we win."
Jordan said he didn't blame pitchers for being careful with McGwire.
"I don't think it's that they're not pitching to him, it's that they're just missing," Jordan said. "I guess they're just trying to get him to chase something and Mark is a disciplined hitter."
McGwire struck out in the eighth and singled in the 10th, giving him just two fair balls in his last 15 plate appearances. He is 24-for-106 (.226) since the All-Star break with 10 homers and 19 RBIs.
Pittsburgh took a 7-5 lead in the 10th on Kevin Young's RBI double and Jose Guillen's run-scoring grounder, but Jordan followed McGwire's single with a two-run homer off Ricardo Rincon, who also allowed a game-tying solo homer to Ron Gant in the ninth.
It was Rincon's first blown save in 15 chances.
Ray Lankford's RBI single off Jeff McCurry (1-2) finally won it in the 12th, making a winner of Lance Painter (4-0). Lankford has three game-winning hits in extra innings in the last seven days.
"He did it again," La Russa said. "He's got a great toughness about him."
Freddy Garcia, 9-for-17 with four homers and seven RBIs in five games since being recalled from the minors, gave Pittsburgh a 5-4 lead in the ninth with his second homer of the game.
Jason Kendall hit a solo shot and Al Martin had a two-run homer, both in the sixth, for Pittsburgh.
Pat Kelly homered and had an RBI double for St. Louis.
Both starters lasted 5 1-3 innings. Chris Peters, who made his first career start against the Cardinals, gave up three runs and four hits. Darren Oliver allowed four runs and five hits.
©1998 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed