CHICAGO -- After struggling with just one win in 11 previous starts, Chicago Cubs pitcher Edwin Jackson figured it was time for a different approach Sunday afternoon.
"Today I just told myself to come out and have fun," he said.
The change in mindset worked as Jackson (2-8) allowed just one earned run on four hits in seven innings as the Cubs avoided a three-game sweep with a 4-1 victory over the Pittsburgh Pirates at Wrigley Field.
"Sometimes we take the game too seriously and get confined in a bubble," said Jackson, who struck out eight and walked one in his longest outing of the season. "Maybe I was taking it too serious (in previous starts) instead of just relaxing. It is a game."
Jackson got a big lift from third baseman Cody Ransom, who slugged a three-run home run in the seventh off reliever Justin Wilson for the go-ahead runs.
Ransom, who has six home runs in just 20 games, said behind-the-scenes work and preparation have helped him make the most of limited appearances.
"Batting practice, early work, all that stuff," he said. "Take meaningful batting practice, not just (go) out there swinging at whatever. Our hitting coaches and coaching staff do a great job of keeping us ready. It's kind of what I've done my whole career."
Ransom's homer to left brought home Julio Borbon and Darwin Barney.
"I've just got to make a better pitch there (on Ransom)," said Wilson, who took the loss. "It was a good job of hitting. I didn't get it far enough in there and (he) got the barrel to it and got it up in the jet stream blowing out."
Wilson (5-1) had one of his poorest outings of the season after being scored on just once in his previous nine games. He lasted just 1 1/3 innings and allowed three earned runs on four hits.
The victory snapped Chicago's two-game losing streak. Pittsburgh had won two straight over the Cubs at Wrigley Field this weekend before Sunday's loss.
Pirates starter Jeff Locke nursed a 1-0 lead and took a no-hitter through 5 2/3 innings. But he departed after walking a pair, giving up a run-scoring sacrifice fly and his lone hit of the game.
"It was a mixed bag," Pirates manager Clint Hurdle said. "The rhythm -- repeating his delivery -- wasn't where it needs to be. (Locke) kept his mound composure, he continued to compete but he pitched out of the stretch the entire day with runners in scoring position."
Locke allowed just one earned run while walking seven and striking out six.
Jackson picked up his first victory since an 8-2 decision at Washington on May 11. Right-handed reliever Kevin Gregg worked the ninth for his seventh save.
Pittsburgh broke a scoreless tie with a single run in the fourth. Andrew McCutchen led off with a double to left and scored his 400th career run on Garrett Jones' RBI single to center.
The Cubs tied the game in the sixth without a hit, and then Locke the lost his no-hitter by giving up a two-out single.
Ransom led off the inning with a walk and advanced to third on Anthony Rizzo's ground out to second. Scott Hairston drove Ransom home with a sacrifice fly to deep center.
Dioner Navarro ended the no-hitter with a single to left. Locke departed in favor of Wilson, who got out of the inning by striking out Starlin Castro.
The Cubs open a four-game home series with the Reds at 7:05 p.m. Monday. Right hander Scott Feldman (5-4, 2.84 ERA) goes against Cincinnati righty Homer Bailey (3-4, 3.84 ERA).
Right-hander Gerrit Cole makes his major-league debut on Tuesday as the Pirates open a three-game home series against the Giants. San Francisco counters with right hander Tim Lincecum (4-5, 4.75 ERA).
NOTES: Cole, the No. 1 overall selection in the 2011 draft, went 5-3 with a 2.91 ERA in 12 starts at Triple-A Indianapolis this season. In his last start against Durham, he tossed seven scoreless innings in a 1-0 triumph. ... The Pirates return to Pittsburgh on Tuesday for a six-game home stand, including three apiece against the Giants and Dodgers. They're 21-11 at PNC Park. ... Wilson entered Sunday's game tops among National League relievers in innings pitched (35) and tied for fifth in strikeouts (34). ... Castro remained in the No. 7 spot in the order. The slumping shortstop went 0-for-4 Sunday and is now batting .243. He remains the Cubs' iron man with 255 consecutive games played, the longest active streak in the National League. ... Chicago entered the series finale with a .164 team average (42-for-256) with 14 runs scored in eight games against the Pirates. ... The Cubs were hitting .262 in 31 home games but just .227 in 28 road contests. ... Soriano needs two home runs to tie Albert Belle for 63rd in major-league history with 381 home runs. He has 26 against the Pirates.