BOSTON — Matt Garza allowed six hits in seven innings and the struggling Tampa Bay Rays pulled away with six runs in the eighth inning to beat Boston 9-4 Wednesday night, ending the Red Sox’s seven-game home winning streak.

Garza (9-5) was sharp in his first road game since June 18 when he gave up seven runs in 1 1-3 innings in a 7-4 loss at Florida, the worst start of his career. He threw 49 pitches in the first inning of that game but just 34 in the first three innings against Boston.

He left with a 9-1 lead before the Red Sox scored three runs in the eighth.

Garza has won four of his last five starts after losing three straight.

The Rays won for only the sixth time in 18 games and moved two games behind the AL East leading New York Yankees, who lost 7-0 to Seattle. Boston remained in second place, one game back.

No Red Sox runner got past first base through five innings and, by that time, the Rays had a 3-0 lead against Daisuke Matsuzaka (5-3).

Matt Joyce led off the fourth with a walk and took third on a single by John Jaso. Kelly Shoppach doubled home both runners and scored on a single by Ben Zobrist.

The Red Sox broke through with two outs in the sixth when Garza hit Eric Patterson with a pitch before David Ortiz had an RBI double to pull to 3-1. Boston then stranded two runners in the seventh.

Red Sox right-hander Manny Delcarmen faced five batters in the eighth and all of them scored. His troubles began when he allowed a single to Evan Longoria. Carlos Pena followed with an RBI double and then took third on a single by Joyce. A walk to Jaso loaded the bases and Sean Rodriguez followed with a two-run single.

Ramon Ramirez replaced Delcarmen and Shoppach sacrificed to advance the runners. Jason Bartlett then hit an 0-2 pitch over the left-field wall for his second homer of the season, extending the lead to 9-1.

Garza struck out five, walked two and allowed three runs, two of them scoring in the eighth on Ortiz’s double on the only pitch thrown by Randy Choate. He entered the game after Garza gave up singles to the first two batters, Marco Scutaro and Patterson.

Tampa Bay wasted an excellent opportunity in the first when Matsuzaka had early control problems for his second straight start since coming off the disabled list with a strained right forearm. Last Thursday, he walked three batters and threw 37 pitches in the first inning when Colorado scored twice in Boston’s 13-11 win in 10 innings.

On Wednesday, he also issued three walks in the first — to leadoff batter Zobrist and, with two outs, to Pena and Joyce. Matsuzaka got out of the jam by retiring Jaso on a fly ball to center.

Notes: Boston RF J.D. Drew was scratched from the original lineup with a stiff beck. … Tampa Bay activated OF Gabe Kapler from the disabled list and designated IF/DH Hank Blalock for assignment. … The Rays open a four-game series on Thursday against Minnesota at Target Field, which replaced the Metrodome as the Twins home this year. “I’m really not sad at all” by the change, Tampa Bay manager Joe Maddon said. “One of my most unfavorite stadiums of all time. I’m just being honest.” … Red Sox manager Terry Francona was happy about Doc Rivers’ decision to return as coach of the Boston Celtics. “I’m thrilled. I’ll re-up my tickets as soon as possible,” Francona said.