PITTSBURGH -- The Chicago Cubs keep finding ways to make their miserable season even worse.
They committed four errors, left 12 men on base and blew three leads -- including the last one in the 11th inning of their 7-6 loss to the Pittsburgh Pirates on Tuesday night.
"It seems like we find ways to lose ballgames," said Aramis Ramirez, who was on base six times and scored three runs in Chicago's fifth straight defeat. "The other team isn't beating us. We're beating ourselves right now."
Jose Bautista's bases-loaded walk scored Jose Castillo to cap Pittsburgh's two-run, 11th-inning rally. Xavier Nady had three hits and scored two runs for the Pirates (52-81), who avoided clinching their 14th consecutive losing season.
"Everyone contributed to this win," Nady said. "It's always nice to see that. We'll have to continue to build on this."
Chicago led 4-0 through 4½ innings, and starter Carlos Zambrano was working on a perfect game.
But the Pirates tied it before the sixth inning was over. The Cubs took one-run leads the seventh and the 11th, only to give the advantages away in the bottom half of those frames.
"Basically we gave it to them," Cubs manager Dusty Baker said. "We'd hit into a double play, we gave them the last two (runs with poor defense). Usually we play pretty good defense; we didn't play pretty good defense tonight."
Derrek Lee's RBI single in the top of the inning appeared to be the winning hit, but closer Ryan Dempster couldn't protect the final lead.
With one out, little-used Humberto Cota delivered a pinch-hit single down the left-field line and was replaced by pinch-runner Ian Snell. Castillo followed with a single up the middle before Joe Randa grounded to shortstop Ronny Cedeno.
His throw was mishandled by second baseman Freddie Bynum, allowing Snell to score. Dempster (1-6) intentionally walked Chris Duffy before Bautista's game-winning base on balls.
"It worked out pretty good," said Cota, who was initially angry with himself for not legging out a double. "Ian has more wheels than I have. It feels good. We just have to finish off strong with a good month."
Matt Capps (5-1) got out of a two-on, one-out situation in the 11th to earn the win.
Each of the Pirates' 12 available position players reached base safely or had an RBI. Five relievers allowed only two runs in six innings, all three pinch-hitters had hits and Snell -- a starting pitcher -- scored the tying run.
"Basically the entire team contributed in one way or another," Pittsburgh manager Jim Tracy said. "It's a great effort and I am extremely proud of them."
The Cubs scored twice in the second courtesy of three walks by Pirates starter Paul Maholm, a wild pitch and a groundout. Matt Murton gave the Cubs a three-run advantage when he singled home Ramirez in the third.
The Cubs' fourth run scored when Murton reached on an infield single with Ramirez on second. First baseman Ryan Doumit misplayed the throw from third baseman Jose Bautista, allowing Ramirez to score.
"It's frustrating coming to the ballpark. Some of the guys are down," Ramirez said. "We aren't playing the way we want to play."
The Pirates got back into the game with a three-run fifth.
Nady doubled to right. One out later, four consecutive Pirates reached base. Doumit singled, Castillo reached on a throwing error by Zambrano, pinch-hitter Jeromy Burnitz singled off the high wall in right, and Duffy lined a single to left.
Castillo, Burnitz and Duffy all had RBI in the inning.
Nady scored the tying run in the sixth on another error by Zambrano. With Nady at second and Ronny Paulino at first, Doumit grounded to first. While trying to complete a double play, the return throw from shortstop Ryan Theriot was misplayed by Zambrano, allowing Nady to score the tying run.
"I am making too many mistakes in covering the bases," Zambrano said. "When you're in the big leagues you have to practice it and correct it."
Michael Barrett's two-out double off Marty McLeary scored Ramirez to give the Cubs a brief lead in the seventh.
Rajai Davis doubled for Pittsburgh leading off the bottom of the inning for his first major league hit. He scored on Freddy Sanchez's two-out single to tie it at 5.
Before losing these last two games, the Cubs had won 13 of 15 at PNC Park since May 30, 2004. ... McLeary's appearance was his first major league action since appearing in three games for San Diego in 2004. ... Pittsburgh's Salomon Torres, who worked out of a bases-loaded jam in the ninth, leads the majors with 79 appearances.