ST. LOUIS -- Pedro Alvarez remained calm and cool during his early-season struggles. There was no sense of panic from the Pittsburgh third baseman.
"You have to trust that what you are doing is going to get you back on the right track," Alvarez said. "Good or bad, you have to keep the same mentality."
That even-keel approach has paid big dividends.
The suddenly red-hot Alvarez slammed a two-run go-ahead homer on Thursday afternoon to help the Pirates to a 6-3 victory over the St. Louis Cardinals in front of 40,601 at Busch Stadium.
The win allows Pittsburgh to salvage the final game of the three-game set after giving up 22 runs in losing the first two contests. The Pirates conclude the seven-game road trip with a 3-4 record and head home to begin a nine-game homestand Friday against Cincinnati.
Alvarez's blow, coupled with some power pitching by southpaw starter Erik Bedard and four relievers, enabled the Pirates to move to within three games of the .500 mark.
Bedard, Jared Hughes, Juan Cruz, Jason Grilli and Joel Hanrahan combined to set a franchise record with 17 strikeouts, the most in a nine-inning game in the modern era (1900), according to the Elias Sports Bureau.
In addition, Bedard struck out seven batters in a row during a stretch from the third to the fifth inning. That is also a franchise record.
"I had no idea," Bedard said of the strikeout string. "I don't remember having seven. Somebody told me that when I came in.
"I guess I was in a groove."
Bedard (2-4) captured his second win in a row after four consecutive hard-luck losses to begin the season. His teammates managed just three runs in those four losses.
But Alvarez made sure Bedard's effort would not go to waste with a 2-for-4 performance. The third baseman has three homers in the his past four games, and a streak of nine extra-base hits in nine contests.
Alvarez was hitting .067 on April 20, which included a 2-for-30 run. But he stayed the course and kept believing that his swing would eventually return. He is 15-for-40 since that time and has raised his average to .257.
"He turned the game around when he got us back in front," Pittsburgh manager Clint Hurdle said. "He's started [hitting] and it's built up speed."
Alvarez drove a full-court offering from St. Louis starter Jake Westbrook over the wall in the sixth to put his team ahead to stay. The Pirates added single runs in the seventh, eighth and ninth to take control.
But it was the Alvarez's seventh round-tripper of the season that turned the tide.
"It was a pitch that was a little bit up and away, and I was just fortunate to put a good swing on it and made good contact," Alvarez said.
Westbrook would like to have that pitch back.
"I made one huge mistake -- and it cost us," he said.
The home run proved to be enough on a day when the Pittsburgh pitchers were throwing heat. Bedard's 11 strikeouts were the most by a Pittsburgh southpaw since Oliver Perez fanned 14 on Sept. 9, 2004, against Houston.
Hughes came on and pitched a perfect sixth. Cruz got out of a bases-loaded jam by inducing Allen Craig to ground out to end the seventh. Grilli fanned two in the eighth, as did Hanrahan in the ninth.
Jose Tabata, who had three hits out of the leadoff spot, helped pump the lead to 4-2 in the seventh. He doubled, stole second and scored on a groundout by Clint Barmes. An inning later, Barmes doubled in Garrett Jones to make it 5-2.
Barmes brought the Pirates to within 2-1 with a two-out, run-scoring double in the fourth that brought in Alvarez, who singled with one away.
St. Louis clipped Bedard for two runs in the first on back-to-back RBI doubles by David Freese and Craig with two out.
Bedard needed 56 pitches to get through the first two innings, but allowed just two hits over the final three frames.
Outfielder Nate McLouth replaced Andrew McCutchen in the bottom of the fourth inning. McCutchen was bothered by the stomach flu, but should be fine.
"He showed up with it and he felt OK," Hurdle said. "He went out there and it progressively got worse."
Steve Overbey is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.