BOSTON (AP) -- The Red Sox held onto Mike Napoli at the trading deadline, and he responded a few hours later with a two-run homer off the top of the Green Monster that led Boston over the Tampa Bay Rays 7-5 on Friday night.

The Red Sox had already blown two leads when David Ortiz drew a two-out walk in the seventh inning and Napoli turned a one-run deficit into a 6-5 lead with a drive that landed on the ledge atop the 37-foot-high wall. The 33-year-old first baseman had been on the trading block as someone who would be more useful to a contender than Boston, headed to a second straight last-place finish.

Another subject of trade talks, Alejandro de Aza, had two hits for Boston. Blake Swihart also had a pair of hits for the Red Sox, doubling with one out in the eighth and scoring on a wild pitch to make it 7-5.

More from FoxSports

Junichi Tazawa (2-3) earned the win despite allowing John Jaso's two-run double that gave Tampa Bay a 5-4 lead in the seventh. Koji Uehara pitched the ninth for his 23rd save.

Jake McGee (0-1) pitched one inning, giving up two runs on one hit and a walk.

The Red Sox scored three runs in the first thanks to a wild pitch and two errors. The Rays tied it in the third and, after giving the lead back in the fifth on a double by de Aza, went ahead in the seventh on Jaso's pinch-double.

The teams entered with 9-15 records in July-- tied for the worst in the majors for the month. For the Rays, it was their worst July ever.

TRAINER'S ROOM

Rays: LHP Drew Smyly (torn left labrum) was sent on a rehab assignment to Single-A Charlotte. OF Desmond Jennings (left knee bursitis) will rehab at Triple-A Durham.

Red Sox: OF Hanley Ramirez (left shin) and 3B Pablo Sandoval (left forearm) got the game off. Both will be evaluated again on Saturday.

UP NEXT

Rays: Left-hander Matt Moore (1-2) will try to snap a personal two-game losing streak in Game 2 of the series on Saturday at 1:35 p.m.

Red Sox: Joe Kelly (2-6) will try to win for the first time since June 6.