CHICAGO -- The Cubs started slow and finished slower on Saturday. In between, they did just fine.

Chicago's Ryan Theriot and Marlon Byrd struck out in the bottom of the ninth with the tying run standing on third, as the Pirates beat the Cubs, 4-3, before 41,336 at Wrigley Field. It was Pittsburgh's fifth win in five tries against Chicago this season, and its seventh straight win against the club dating back to last season.

"We almost got there," said Cubs starter Ryan Dempster. "We had a chance there at the end and didn't get it done, but we're going to keep plugging away. We're going to get it turned around."

Does he really believe that?

"Absolutely," Dempster said. "We just have to stay positive."

A good buccaneer moves swiftly, and so has it been with Pittsburgh's version of the Pirates this season. The Bucs have scored in the first inning of all five meetings between the teams.

"The first inning, [Dempster] threw a lot of pitches, walked a couple and they scored three," said Cubs manager Lou Piniella. "Then he held them at bay. We had our chances, especially there in the bottom of the ninth."

Before the game, Piniella spoke of his need for Dempster to pitch deep into the game to give a break to his beleaguered bullpen. Dempster got off to a bad start to that end by walking the first two Pittsburgh batters of the game, Aki Iwamura and Andy LaRoche. Red-hot Andrew McCutchen, who had five hits against the Cubs on Friday, singled to drive home Iwamura. One batter later, Ryan Church doubled to plate LaRoche and McCutchen, putting the Bucs up, 3-0.

Dempster was rock solid after that, falling just one inning short of Piniella's pregame wish of eight frames from his righty. After Church's double, Dempster retired 11 batters in a row. He struck out nine, walked five and ran his pitch count up to 123 before departing for pinch-hitter Kosuke Fukudome in the bottom of the seventh. It was the most pitches a Cubs hurler has thrown this year, topping the total of 121 thrown by Carlos Zambrano on April 15, and the most pitches Dempster has thrown in a game since Sept. 19, 2002.

"When you walk the first two guys, it makes the inning a whole lot tougher," said Dempster. "I was one pitch from getting out of the inning and didn't make that pitch. After that, I threw the ball well." Despite the pitch count, Dempster was still feeling strong during his final inning. "I felt good. I felt strong on the last hitter," Dempster said. "Through seven innings, you don't want to throw that many pitches and I did that to myself, but I worked hard during the offseason and now during the season, so my body felt good and my arm felt good."

The Cubs missed two choice opportunities to tie the game.

In the bottom of the third, Dempster led off with a double just inside the first-base bag. He went to third on Ryan Theriot's single. Marlon Byrd hit a liner to short, which Pirates shortstop Ronny Cedeno tracked down with a lunging grab. Aramis Ramirez showed further signs of shaking his early-season slump, doubling to bring home Dempster and Theriot and trimming the lead to one. Geovany Soto followed with a single, but Church, Pittsburgh's left fielder, threw out Ramirez at the plate in a play that wasn't particularly close.

That kept the Pirates on top, 3-2, a score which held until the ninth. In the top half of the inning, Pittsburgh first baseman Jeff Clement hit a line-drive homer into the left-field bleachers. The blow came off Cubs closer Carlos Marmol, who hadn't allowed a home run since Sept. 30 of last season, a string of 16 appearances. Given what followed, the insurance run was crucial to the Bucs' cause.

"Nobody can be perfect," said Piniella.

In the bottom of the ninth, Cubs rookie Starlin Castro worked a one-out walk off Pittsburgh closer Octavio Dotel. That brought up Fukudome, who ran a full count against Dotel, then looped a fly ball into the right-field corner against an outfield that was shaded the opposite way. Castro raced home and Fukudome slid into third, 90 feet away from tying the score.

Piniella had to like his chances at that point. One out. A fast runner on third, with Theriot and Byrd due up.

"Did I feel good about it? Yeah, I felt good about it," said Piniella, when asked about the situation. "I don't feel good about it now, but I felt good about it then."

Byrd and Theriot entered the game tied for second in the National League in hits. Theriot went down swinging on a 2-2 fastball that registered at 94 mph, the hardest pitch Dotel threw in the game. That brought up Byrd, who was hitting .345 entering the contest. Dotel jumped ahead of him with a couple of sliders. Then, with the sell-out crowd on its collective feet, he got Byrd swinging on a cutter to end the game.

Dotel, who is 7-for-9 in save opportunities, decided to trust his catcher.

"In my head was, 'You cannot let that run come in to home plate,'" Dotel said. "'Don't be afraid to throw whatever [Ryan] Doumit calls.' I went from there."

Of the Pirates' closer, Byrd said, "He closed the door. We couldn't get it done. I had my last chance with two outs, got to at least put the ball in play. I didn't even do that. So tip your hat to him, and I slap myself in the face for not even putting it in play."

Still, the key at-bat in the inning was probably the one by Theriot. Coming into the game, he was 4-of-7 with a walk and a sacrifice fly this season with a runner on third and less than two outs and had not been fanned in those situations.

"You're just trying to make contact," said Theriot. "He made a few good pitches. He kept the ball down with the breaking ball early and kind of elevated with the fastball there late."

The Cubs' offense, which has struggled for most of May, stranded a single runner in eight of the nine innings. After the third inning and before the ninth, the only runner that got into scoring position for Chicago was Derrek Lee, who barely beat out a throw for a two-out double in the fifth. He was stranded when Ramirez flied out to left to end the threat.

The Cubs have now lost four of the first five games of their eight-game home stand, and nine of 11 overall, falling a season-worst seven games under .500. Chicago ranks third in the league in batting average and fourth in homers. However, they've tended to score in bunches. The Cubs have scored three runs or fewer in 18 of their 37 games and are 1-17 in those games. The search for consistency continues.

"Boy, that big hit is really elusive," said Piniella, later adding, "What are we going to do? We've tried a little bit of everything."