ST. PETERSBURG, Fla. -- Josh Beckett had a shaky start, got stronger as he went and won his rubber-game matchup with James Shields on Sunday.
Beckett rallied to allow three runs over six innings, and the Boston Red Sox, with two home runs and 14 hits, beat the Tampa Bay Rays 7-3 at Tropicana Field.
Mike Aviles hit a two-run homer, Daniel Nava had a solo shot and Jacoby Ellsbury and Will Middlebrooks each had three hits for the Red Sox, who took two of three in the series and moved back to one game over .500.
Adrian Gonzalez, who missed the first two games in the series with back spasms, went 2-for-4 with a run and an RBI.
Tampa Bay lost for the 11th time in 17 games and the 14th time in 22 games, and they fell to 25-21 at home after starting 13-1.
Shields (8-6), who entered the game leading the majors in hits allowed, gave up six runs on 11 hits, including the two home runs, in only five innings. He has allowed 61 hits over his last six starts, including double-digit hits in each of his last four outings.
Beckett (5-7) allowed singles in the first inning to the first three batters and yielded three runs in the first inning. But with help from his team's bats, the right-hander came back to improve to 5-0 in his last eight starts against the Rays dating to September 2009.
The Rays failed to score over the final eight innings but managed to get the tying run to the plate in the ninth.
Alfredo Aceves walked the bases loaded with two out to bring up Hideki Matsui, but the veteran flew out to right to end the game.
Three Boston relievers combined to keep the Rays off the board in the final three innings.
Gonzalez's RBI single in the first after Shields walked Nava and David Ortiz gave the Red Sox a 1-0 lead.
The Rays came back with three in the bottom of the frame.
Will Rhymes, Carlos Pena and Ben Zobrist opened with singles, the latter of which hit off Beckett's glove and drove in a run.
Beckett struck out B.J. Upton and Matsui but then hit Jeff Keppinger with a pitch, and Desmond Jennings followed with a two-run single.
It was mostly all Red Sox after that.
Aviles tied the game 3-3 in the second, teeing off on a first-pitch slider from Shields for a two-run homer after Middlebrooks singled.
The Sox then powered to a 6-3 lead in the fifth.
Nava homered to right to start the inning. After Ortiz and Cody Ross reached on one-out singles and Jarrod Saltalamacchia walked, Middlebrooks ripped a single past a diving shortstop Elliot Johnson for a two-run single.
Shields didn't come out for the sixth, and reliever Jake McGee wasn't sharp while facing five batters.
Ellsbury singled, Nava walked and Ortiz singled to load the bases before McGee struck out Gonzalez for the first out.
Manager Joe Maddon called on righthy Burke Badenhop to face Ross with the bases loaded. Ross lifted a fly ball to center for s sacrifice fly, and Boston led 7-3.
The Rays threatened to rally in the seventh when Pena opened with a single against newly recalled Junichi Tawaza and Ben Zobrist laced a single to right. But Zobrist was thrown out after rounding first, and Mark Melancon came on to retire Upton and Matsui.
NOTES: The Red Sox placed reliever Scott Atchison in the 15-day DL with right forearm tightness and recalled Tazawa from Triple-A Pawtucket. Atchison leads the Boston pen with a 1.76 ERA over 37 appearances and 46 innings. ... ... Gonzalez, who returned to the lineup after missing the first two games of the series, said his back spasms started when he bent down to talk to a child in a stroller in Tampa. ... Outfielder Mike Sweeney was given a second consecutive day off with hamstring tightness. ... Outfielder Carl Crawford went 2-for-5 with a run for Pawtucket on Saturday night in what may have been his final minor rehab assignment. He told reporters he will be with Boston on Monday for the start of a home stand. ... Rays right fielder Matt Joyce (oblique strain) joined Triple-A Charlotte on Sunday for a planned brief rehab assignment. ... Johnny Damon and Casey Kotchman, key players for the Rays 2011 playoff team, return to Tropicana Field on Monday with the Indians.