Andrew McCutchen drove in two runs, Jeff Locke pitched into the eighth inning, and the Pirates beat the Tampa Bay Rays 6-5 on Tuesday night.
The Pirates have the NL's best record (27-18) since May 6, and moved above .500 (39-38) for the first time since starting the season 7-6.
Pittsburgh, which took a 6-1 lead, is 18-15 in games decided by a run.
"You continually try and create separation," Pirates manager Clint Hurdle said. "You need them all. You don't take things for granted. Obviously it's another one-run game for us. We play a bunch of them."
The Pirates have won five straight road series after losing seven in a row.
McCutchen had an RBI single during a three-run third inning that put the Pirates ahead 4-0. The 2013 NL MVP had two RBIs in Pittsburgh's 8-1 win Monday night over the Rays.
Locke (1-1) allowed three runs and eight hits over 7 1-3 innings. His night ended in the eighth when Evan Longoria trimmed the Rays' deficit to 6-3 with a two-run homer.
"I'm just throwing strikes," Locke said. "Challenge them a little more."
Mark Melancon got his 13th save despite giving up Brandon Guyer's two-run single in the ninth that pulled Tampa Bay to 6-5.
Chris Archer (4-5) gave up five runs and seven hits in seven innings for the Rays, who have lost 20 of 28. The right-hander had given up nine runs — four earned — over 40 2-3 innings in his previous seven starts.
"We just tried to stay selectively aggressive in the zone," Hurdle said.
Pirates left fielder Starling Marte left in the fifth inning with concussion-like symptoms after a head-first slide during a failed stolen base attempt. He made contact with Rays second baseman Sean Rodriguez on the play.
Marte was sent to a local hospital for a CT scan.
Gregory Polanco started the first with a walk, stole second and advanced to third on catcher Jose Molina's throwing error, and scored to make it 1-0 on a grounder by McCutchen. Polanco has reached base in all of his 14 games since being recalled from Triple-A Indianapolis on June 10.
Tampa Bay got within 4-1 in the fifth when Logan Forsythe hit a two-out triple, a routine-looking fly ball that Polanco lost and Jose Molina followed with an RBI double. Molina, who has two RBIs in 43 games this season, is 2 for 34 with runners in scoring position.
"There's a lot of good things to draw from tonight, but we can't continue to lose this type of game," Rays manager Joe Maddon said. "The moral victories are not what we're looking for right now. We're looking for the actual victories."
Marte hit a run-scoring single and Neil Walker had a sacrifice fly in the third. Josh Harrison had a sixth-inning RBI single and Russell Martin hit a solo homer in the eighth.
Walker returned after being on the 15-day disabled list since June 9 because of an appendectomy.
NOTES: Rays SS Yunel Escobar left with a sore right shoulder and will not start Wednesday's game. ... Hurdle should announce Wednesday when RHP Gerrit Cole (right shoulder fatigue) will return to the rotation. Cole threw a simulated game Monday, which lines him up to start this weekend. ... Tampa Bay C Ryan Hanigan was scratched due to neck stiffness. ... Maddon said RHP Jeremy Hellickson (right elbow surgery) will need at least one more minor league start before returning. ... NASCAR driver Aric Almirola took batting practice and gave Maddon a Rays' racing helmet. ... Tampa Bay LHP David Price (5-7) and Pirates RHP Charlie Morton (4-8) are Wednesday's scheduled starters. Price, the subject of trade speculation, said he has thought about the situation and it's the reason why he's been in a "bad mood" recently.