ST. LOUIS (AP) -- Over and over again, the scene was repeated. St. Louis hitters just kept trudging back to the dugout, bats on their shoulders.
Erik Bedard struck out a season-high 11, including a team-record seven in a row, and the Pittsburgh Pirates set a club mark by fanning 17 batters Thursday in a 6-3 win over the Cardinals.
"I was throwing pitches and they were swinging through it," Bedard said. "I guess I was in a good groove. I don't remember getting seven."
Bedard (2-4) was pulled after five innings and 104 pitches, keeping St. Louis off-balance with an assortment of soft tosses.
Pittsburgh relievers kept piling up the strikeouts - the 17 Ks were the most by Pittsburgh in a nine-inning game since 1900, the team said in citing research by the Elias Sports Bureau.
"It's a way to keep them from scoring runs," manager Clint Hurdle said. "But as you saw, they had the tying run at the plate at the end of the game, so they kept fighting."
The strikeouts were the most by the Pirates in any game since they fanned 18 Cubs over 20 innings in 1980.
The last time the Cardinals fanned so often in a nine-game game was 1989, when they struck out 18 times against the Cubs. St. Louis struck out 19 times in a 20-inning loss to the Mets in 2010.
In all, 11 St. Louis hitters struck out, including three pinch hitters. Six players fanned twice. David Freese , who entered second on the team with 23 strikeouts, was the only starter who didn't strike out.
"We've talked about it before," manager Mike Matheny said. "Timely hitting is one of those key ingredients to winning, and we didn't get as many of them as we needed."
The Cardinals drew seven walks for the fourth time to tie a season high, and lost for the first time.
Pedro Alvarez hit a go-ahead, two-run homer in the sixth as Pittsburgh avoided a sweep in a game that lasted 3 hours, 26 minutes, the longest regulation affair for both teams this season.
Clint Barmes had a pair of RBI doubles for the Pirates, who completed a 3-4 trip and will have 18 of the next 25 at home to end May. Jose Tabata , a career .343 hitter against St. Louis, added three hits and a steal.
"It was showtime," Hurdle said. "We had the people in there we wanted to have in the game. We threw all the chips in. It was probably a little more entertaining than we probably would have liked, but we got it done."
Jake Westbrook (3-2) lost to Pittsburgh for the second time in three starts, giving up four runs in 6 1-3 innings.
The NL Central-leading Cardinals have won seven of their first eight series, but four times have failed to complete a sweep after winning the first two games.
"You guys are going to get sick of me saying it but I want to keep telling you, we just go one at a time," Matheny said. "We're not thinking about winning a series, we're not thinking about sweeps, we're thinking about winning today's game."
The Cardinals outscored the Pirates 7-0 in the first inning in the series, and got off to another fast start against Bedard after doubles by Rafael Furcal , Freese and Allen Craig made it 2-0. Matheny played it conservative in the first, though, with Jon Jay sacrificing Furcal to third.
"We've been doing that a lot, almost every game," Matheny said. "Not necessarily small ball, that's just good baseball."
St. Louis had just two hits the next six innings and came up empty with the bases loaded twice, with Matt Holliday hitting a comebacker to end the second and Craig grounding out against Juan Cruz to end the seventh.
Bedard was untouchable between the third and fifth, fanning Craig, Shane Robinson , Tyler Greene , Tony Cruz , Westbrook, Furcal and Jay before Holliday singled with two outs in the fifth.
Though four strikeouts shy of his career high, Bedard's total was the highest by a Pirates lefty since Oliver Perez fanned 14 Astros on Sept. 9, 2004.
Bedard has won his last two starts after dropping his first four while pitching well without much support. He hasn't allowed more than two earned runs in any of his starts.
Craig hit an RBI double off the base of the center field wall against Joel Hanrahan with two outs in the ninth. The Cardinals had the tying run at the plate before Hanrahan struck out Matt Carpenter .
Jay was 0 for 2 with two walks and a sacrifice for St. Louis, ending his season-best 11-game hitting streak in which he batted .488 (21 for 43).
Neil Walker singled to start the Pittsburgh sixth and Alvarez followed with his seventh homer and third in four games for a 3-2 lead, the Pirates' first edge of the series.
It was the first homer allowed on the year by Westbrook, a sinkerballer. Westbrook has never beaten the Pirates, going 0-5 with a 5.06 ERA in 10 games with six starts.
"You saw more fly balls than you've seen from Jake all year," Matheny said. "Typically, when he gets hurt he's up."
Tabata doubled with one out in the seventh to chase Westbrook, stole third against reliever J.C. Romero and scored on Alex Presley 's groundout. Garrett Jones and Barmes hit consecutive doubles with two outs in the eighth off Victor Marte , and Nate McLouth added a run-scoring single off Kyle McClellan in the ninth.
Cardinals pitchers combined for five strikeouts.
NOTES: Pirates star Andrew McCutchen , who got his first day off on Wednesday, left with stomach flu in the fourth. ... Cardinals rookie Lance Lynn is the first Cardinals pitcher to win his first five starts since Bob Tewksbury won his first six in strike-shortened 1994. ... Kyle Lohse (4-0, 1.62) goes for his fifth win Friday when St. Louis opens a three-game series at Houston. Lohse was 2-0 with an 0.60 ERA against the Astros last year. ... Kevin Correia (1-1, 2.42) starts for the Pirates in the opener of a three-game series against the Reds Friday. ... Westbrook's stolen base in the second was the first by a Cardinals pitcher since Joel Pineiro on April 15, 2009, at Arizona.