CHICAGO - Jeff Locke was having such a hard time throwing strikes that he didn't even realize he was working on a no-hitter.
The left-hander held Chicago hitless into the sixth inning Sunday but Cody Ransom hit a tiebreaking, three-run homer off reliever Justin Wilson in the seventh and Edwin Jackson pitched the Cubs to a 4-1 victory over the Pittsburgh Pirates.
Locke went 5 innings without allowing a hit but also walked seven batters.
OUT AT SECOND -- Chicago shortstop Starlin Castro tags out Pittsburgh's Andrew McCutchen during the ninth inning of Sunday's game in Chicago. The Cubs won, 4-1.
-- Associated Press
"I didn't really know that I didn't give up any hits because there was somebody on base every inning," he said. "Multiple people the whole time. I was pitching from the stretch no matter what."
Locke gave up his first hit, a sharp single to left field by Dioner Navarro, in the sixth after the Cubs tied the score at 1 without a hit.
"Definitely kind of a freak game," Locke said. "Something that I haven't been a part of before."
Locke was pulled after Navarro's hit. He struck out six but threw 100 pitches in 5 innings.
"It was a mixed bag," Pirates manager Clint Hurdle said. "The rhythm and repeating his delivery wasn't where it needs to be. He kept his mound composure. He continued to compete. But he pitched out of the stretch the entire day with runners in scoring position."
Ransom connected off Wilson (5-1) for his sixth home run of the season. Darwin Barney and Julio Borbon were on base.
"I just have to make a better pitch there. Good job of hitting," Wilson said. "I didn't get it far enough in there and he got the barrel to it and it got up in the jet stream and the ball went out."
Jackson (2-8) had his best and longest outing of a frustrating season, striking out eight in seven innings. He allowed four hits and a walk as the Cubs salvaged the finale of a three-game series.
"Sometimes we take the game too serious and we are kind of confined in a bubble," Jackson said. "Today I was just able to come out of that bubble and have some fun out there."
Kevin Gregg pitched the ninth for his seventh save in seven chances, completing a six-hitter.
Chicago manufactured the tying run in the sixth before Navarro's hit, and it was Ransom's alert baserunning that led to the tying run. He went from first to third on an infield grounder and later scored on Scott Hairston's sacrifice fly.
Locke issued a leadoff walk to Ransom in the sixth. Pirates second baseman Neil Walker fielded Anthony Rizzo's grounder in the hole and had to race to the bag to get the putout because first baseman Garrett Jones was out of position trying to field the ball. No one covered third on the play and Ransom took the extra base. After Alfonso Soriano walked, Hairston's sacrifice fly to center made it 1-all.
Pittsburgh took a 1-0 lead in the fourth when Andrew McCutchen doubled and Jones followed with an RBI single.
Pirates pitchers dominated most of the series, allowing two earned runs in the first 23 2-3 innings.
"Their whole pitching staff is good," Ransom said. "We were no-hit through five innings all three days."
NOTES: Navarro reached base four times, walking twice and singling twice. ... Hurdle said pitcher Charlie Morton could soon be considered for a return to the team after throwing 96 pitches in 6 1-3 innings Saturday during a rehab assignment with Triple-A Indianapolis. Morton had elbow surgery and has been on the disabled list since March 22. Hurdle called it the right-hander's "best outing to date." ... Pittsburgh RHP Gerrit Cole makes his major league debut when the Pirates return home for six games starting Tuesday. The first pick in the 2011 draft will square off against San Francisco RHP Tim Lincecum (4-5, 4.75 ERA).