Sam Fuld's RBI single in the sixth inning proved to be the difference as the Tampa Bay Rays snuck past the San Francisco Giants, 4-3, in the rubber match of a three-game series.
Wil Myers hit a two-run homer for the Rays, who remained one game behind Boston for the AL East lead. Evan Longoria had an RBI.
"My at-bats today overall were so much better than they've been," Longoria said. "That's a step in the right direction."
Tampa Bay starter Roberto Hernandez allowed three runs on eight hits over 4 2/3 innings. Alex Torres (4-0) tossed 1 1/3 scoreless innings of relief to pick up the win.
Brandon Crawford knocked in two runs for the Giants, who went 3-3 on a six- game road trip. Buster Posey added an RBI.
"We're not getting any production from our leadoff hitters," San Francisco manager Bruce Bochy said. "We're definitely going through a tough time."
Guillermo Moscoso, making his first start of the season, gave up three runs on four hits while walking four over 4 2/3 innings. Jose Mijares (0-3) allowed one run over 1 1/3 innings of relief to take the loss.
The Giants scored once in the first inning. With one out, Marco Scutaro, Pablo Sandoval and Posey hit three straight singles to plate a run.
Tampa Bay responded with two runs in the bottom half of the first. Ben Zobrist walked and scored on Myers' blast over the wall in left.
San Francisco used a two-run fourth to take the lead back. Brandon Belt walked and Hunter Pence singled to start the frame. Roger Kieschnick grounded into a fielder's choice to put runners on the corners. Crawford's two-run triple to right-center field made the score 3-2.
The Rays switched the momentum again by scoring one run in the fifth and sixth innings. Fuld walked to start the fifth, stole second and raced home on Longoria's two-out single to left.
Tampa Bay went ahead on Fuld's RBI single in the sixth. Yunel Escobar walked, advanced to second on Jose Molina's groundout and scored on Fuld's single to right.
Jake McGee, Joel Peralta and Fernando Rodney each tossed a scoreless inning of relief. Rodney picked up his 27th save of the season.
Moscoso was replacing an ineffective Barry Zito in the rotation ... Rays outfielder Desmond Jennings was out of the lineup due to a sprained left middle finger.