Updated

Aaron Cook went six weeks without a win. So when he finally got one, he enjoyed it.

Cook pitched six solid innings to stop his five-game losing streak, Jacoby Ellsbury homered and drove in three runs, and the Boston Red Sox beat the sliding Tampa Bay Rays 5-2 on Monday night.

"It's one of those things I try to put out of my mind, to just go out there and try to be myself every start and try to give us a chance to win some baseball games. Everything worked out tonight," Cook said. "We played really well tonight and it's nice to shake hands after a game."

Cook (4-10) allowed one run and five hits for his first victory since Aug. 6.

"I got in a real good rhythm early. I had my sinker working and I actually had quite a few cutters tonight. I usually don't throw that many," he said. "(The cutter) is one of those pitches that's really starting to open up the outside part of the plate when I keep 'em honest inside."

Ellsbury hit a two-run homer with two outs in the sixth for Boston's first hit off Rays starter Alex Cobb. He added an RBI single during a three-run seventh for the Red Sox, who were eliminated from playoff contention Sunday.

Jose Iglesias was hit by Cobb's pitch with one out and scored on Ellsbury's homer, which put the Red Sox ahead 2-1.

"For five innings it looked like we didn't have any gas in our tank, and then Iggy ignited us a little bit," manager Bobby Valentine said. "And Ells took a lot of time in between pitches and hit a 3-1 pitch, and he gave us the lead."

Rich Hill and Junichi Tazawa each threw a scoreless inning of relief with two strikeouts. For the 10th time this season, Cook had one walk or less and one strikeout or less, becoming the first pitcher to have 10 such starts since Detroit's Bill Gullickson in 1992.

"It's been a little time in between wins. Maybe he'll get on a little roll," Valentine said.

Tampa Bay, coming off a 1-5 road trip to Baltimore and New York, fell 5½ games behind the AL East-leading Yankees. The Rays have scored just 21 runs over the last seven games.

"This has been ongoing. ... This is a seasonal misadventure," manager Joe Maddon said. "We've been able to remain solvent because our pitching has been so good."

B.J. Upton had three of Tampa Bay's six hits.

Cobb and catcher Jose Molina got into a heated discussion in the dugout after the top of the sixth when Boston took a 2-1 advantage. There was a wild pitch and passed ball during the inning.

"We're both really into that game, and we needed to win that game," Cobb said. "I honestly don't really know what the argument was about, still. We'll work things out. We'll talk about it tomorrow, or whatever, and leave it behind us."

Molina declined to comment as he was leaving the clubhouse.

"I'm not unhappy," Maddon said. "That's overblown sometimes. That can actually be a good thing. It's fine right now. We discussed everything. It's all good."

Rays slugger Evan Longoria sat out because of what Maddon called heavy legs. Maddon expects the third baseman, who missed 85 games this season due to a partially torn left hamstring, to be back in the lineup Tuesday.

Cobb (9-9) allowed one baserunner — a two-out walk in the second to Jarrod Saltalamacchia — through five innings. The right-hander made a nice defensive play to end the second, grabbing a hard grounder by Ryan Lavarnway and throwing the catcher out at first.

Cobb was pulled after James Loney singled and Saltalamacchia walked to start the seventh. Boston loaded the bases with no outs when Lavarnway reached against Burke Badenhop after shortstop Ben Zobrist misplayed a grounder for an error.

After pinch-hitter Mauro Gomez hit a two-run single off J.P. Howell, Ellsbury made it 5-1 with a run-scoring single against the left-hander.

"I like being in the situation where I can help my team win and have an opportunity to drive in a run," Ellsbury said.

Cobb, who had won five consecutive decisions, gave up four runs and two hits in six-plus innings.

Tampa Bay took a 1-0 lead in the fifth when Luke Scott scored from third on Ryan Roberts' sacrifice bunt. Zobrist had an RBI grounder in the ninth.

NOTES: Boston is 14-30 since Aug. 1. ... The announced attendance was just 11,722. ... Ellsbury has seven RBIs over his last nine games. ... Tazawa has allowed two baserunners while striking out 14 in his last eight appearances. "You can't throw the ball any better than he's throwing it," Valentine said.