PITTSBURGH -- For some, the game was as good as over. The Pirates had been sloppy, managing to fall behind San Diego by five runs after just two innings. The Padres, for their part, looked strong, ready to finish off the sweep while extending the home team's losing streak to four games.Might as well have marked the beginning of another late-season collapse in Pittsburgh, as far as some folks were concerned. And then, in the fourth inning, starter Ross Ohlendorf and the Padres got a little sloppy, too. The Pirates loaded the bases on a walk, an error and a single. One run came in on another walk. In stepped Clint Barmes, who had already recorded two errors in the field. In the batter's box, he made up for them. Barmes swung at the fifth pitch of the at-bat and sent it hurtling down the left-field line. The ball smacked into the foul pole, giving the shortstop his first career grand slam and the Pirates their first lead since Friday night. The Bucs would go on to fight off the sweep and stand up to the Padres, taking Sunday's series finale, 11-5, in front of 35,352 fans at PNC Park. "I was just trying to put a barrel on the ball, and do something to at least get one run in, or to keep it going," Barmes said. "I hit it well, obviously. At that point, as soon as I hit it, I saw it starting to hook, and it was one of those where I was just hoping it stayed fair." The win snaps a three-game losing streak for the Pirates, who are 4 1/2 games behind the Reds in the National League Central. It also halts an 11-game skid the Bucs had endured against the Padres at PNC Park. "That got about as ugly as you wanted it to get through the top of the fourth," Pirates manager Clint Hurdle said. "We're pretty good. We're not perfect. We'll confuse you. We'll probably anger you from time to time, but we're going to let it all hang out. We're going to play hard, and they found a way to dig one out of the dirt today." All in all, the Pirates sent 14 men to the plate during their phenomenal fourth inning, scoring nine runs on six hits in that frame alone. Pittsburgh hadn't scored nine runs in one inning since July 20, 2010, when it racked up that many against Milwaukee at home. The run support must have delighted Pirates starter Erik Bedard, who isn't quite used to so much of it. One of baseball's three pitchers with 12 losses, Bedard earned the win on Sunday, allowing five runs -- three earned -- on five hits in five innings. He issued four walks and struck out six batters. "Early on, I wasn't really throwing strikes with my fastball," Bedard said. "Later on, I was throwing a lot of strikes with my curveball, so that's what helped me out to finish the game. "I did the best I could with what happened. Stuff like that's going to happen, so you've just got to bear down, pick them up just like they pick you up when you give up runs." Bedard scored Pittsburgh's first run, too. Soon after the pitcher doubled down the left-field line in the third inning, Neil Walker drove him in with a single up the middle. It was Bedard's fourth hit and first run scored this season. He scored another during the comeback fourth inning. Walker also hit a solo home run in the seventh inning. The big fly was his fifth hit of the game, giving him three career five-hit performances. "He's really hitting good right now," Hurdle said. "He's a ball-striker, and he works very hard at it, offensively, as hard as he works on his defensive game. "The last six weeks, two months in particular, he's probably swinging the bat offensively as good as any middle infielder in the game." Way before Walker's blast, though, San Diego scored four runs in the first inning and one in the second. After giving up a leadoff homer to Chris Denorfia, Bedard let in another run on an RBI single by Jesus Guzman. Two more runs scored in the next at-bat, when Barmes made a rare error at shortstop on a grounder by Cameron Maybin, tossing the ball into right field. "Denorfia set a good tone with that homer," Padres manager Bud Black said. "We've been doing that a little bit lately, homering in the first inning. From there we kept going, built that lead. Ohlendorf threw the ball well the first three innings and made some pitches. Then they ambushed us there in the fourth, and we couldn't make pitches along the way to stem the tide." The error by Barmes was his first in 36 games. He registered another one in the fourth inning, too, but it could just as easily have been given to third baseman Pedro Alvarez. Both players went for a Chase Headley grounder, and neither of them made the play. In the second inning, the Padres added their final run, this one coming off a dribbler by Headley that rolled along the first-base line. Catcher Michael McKenry went out to make the play, and nobody covered home. Logan Forsythe, who had doubled earlier in the frame, scampered toward the plate to push San Diego's lead to five, which of course turned out to be not nearly enough. With the sweep averted, Pittsburgh now turns its eyes toward the Dodgers -- a competitor in the NL Wild Card race. Los Angeles comes to town for a four-game series beginning on Monday. "We needed a good feeling," Hurdle said. "The way we've gone the last three games ... it's almost like getting slapped by your girlfriend in front of your mother. Number one, it gets your attention. Number two, it takes you [to] a place you really don't want to be. But you've got to find your way out, and we were fortunate enough to find a way out today."
Mark Emery is an associate reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.