Gomes tied it at 6 with a two-run shot in the ninth off Red Sox closer Jonathan Papelbon, but Julio Lugo drew his second bases-loaded walk and Kevin Youkilis followed with a three-run double in Boston's big 12th inning.
Lester, whose rookie season ended last year when he was diagnosed with lymphoma, gave up four runs and six hits in 6 2-3 innings. The 23-year-old left-hander left the game with a 5-4 lead, after going six innings last Monday to lead the Red Sox to a 6-2 win over the Cleveland Indians.
It was Papelbon's second blown save in 25 chances, the other coming May 1 against Oakland.
Mike Lowell had a one-out single in the 12th off Brian Stokes (2-7), who then loaded the bases with consecutive walks to Jason Varitek and Coco Crisp. After Lowell was forced at the plate on Alex Cora's grounder, Lugo walked to put Boston up 7-6. Jae Kuk Ryu replaced Stokes and gave up Youkilis' double to deep right-center and a two-run double to Manny Ramirez.
Kyle Snyder (2-2) threw two scoreless innings for the win, helping the Red Sox take a nine-game lead over the New York Yankees in the AL East. New York lost 7-5 at Baltimore.
David Ortiz had a run-scoring single and Ramirez hit a sacrifice fly to put Boston up 5-2 in the seventh.
Gomes and Josh Paul had seventh-inning solo homers off Lester to pull Tampa Bay within 5-4. The Devil Rays have allowed 83 runs during their eight-game losing streak, and are 5-25 since June 25.
Tampa Bay was without All-Star left fielder Carl Crawford and infielder Ty Wigginton. Crawford has a sore right wrist, while Wigginton was traded to Houston for reliever Dan Wheeler earlier in the day.
Crawford was hurt diving for a ball Friday and will be a gametime decision Sunday.
James Shields gave up three runs and six hits in five innings. The Devil Rays right-hander is 2-6 with one no decision over his last nine starts after starting the season 6-0.
The Red Sox took a 2-0 lead in the second on an RBI single by Varitek and Lugo's two-out bases-loaded walk. J.D. Drew made it 3-0 on a third-inning RBI single.
Tampa Bay got within 3-2 on sacrifice flies by Delmon Young in the fourth and Carlos Pena two innings later.
The announced crowd was 36,048 was the fourth sellout this year and eighth overall at Tropicana Field. A large number were Red Sox fans.
Devil Rays manager Joe Maddon was ejected in the 11th for arguing a check-swing call. ... Ortiz has a 13-game hitting streak. ... Tampa Bay plans to recall SS Ben Zobrist from Durham Sunday to take Wigginton's spot on the roster.