The Red Sox were down to their last strike before Middlebrooks came through with his clutch hit that gave Boston its second straight win.
Junichi Tazawa then escaped a jam in the bottom of the ninth to preserve the victory.
Desmond Jennings and Luke Scott both had RBI singles in the sixth to give Tampa Bay a 3-1 lead and that was still the score heading into the ninth.
Boston managed only three hits through eight innings and Fernando Rodney was called on in the ninth for the Rays.
Rodney, however, walked the bases loaded with one out, then fanned Stephen Drew on three pitches. That brought up Middlebrooks, who on a 1-2 count cleared the bases with the only hit of the inning.
Tarawa (3-2) picked up the victory by working the final two innings. He put runners on first and second with two away in the Tampa Bay ninth before getting James Loney on a grounder to short that ended the contest.