The Rays didn't lose or gain any ground in their quest to reach the postseason, as they remain 6 1/2 games behind the American League East-leading Yankees and 5 1/2 games back of the A's and Orioles for a Wild Card spot.
Trailing, 4-1, in the ninth, Matt Joyce singled off Boston closer Andrew Bailey to open the inning, and Jeff Keppinger followed suit with a single through the middle. Luke Scott's groundout to first moved the runners into scoring position for Carlos Pena, who singled to right to cut the lead to two runs and bring Stephen Vogt to the plate.
Looking for his first hit of the season after going 0-for-19, Vogt worked the count to 3-0 when pinch-runner Rich Thompson stole second. The count moved to 3-2 when Vogt walked.
Elliot Johnson pinch-ran for Vogt, and Desmond Jennings singled through the middle to tie the score at 4 and chase Bailey.
"It's inexcusable," Bailey said. "There's no other way to describe it. I've got to get that job done and get out of the inning."
Vicente Padilla took over for Bailey and fell behind 2-0 to Upton, who swung at a 94-mph four-seam fastball and missed badly. Padilla then came back with the same exact pitch, but Upton squared up and deposited the ball over the center-field wall.
"I fell behind 2-0, swung at a pitch I didn't want to and he left one where I could hit it," said a grinning Upton.
For Upton, the blast gave him his fourth career walk-off home run as well as his sixth career walk-off hit. In addition, he tied his career high for home runs with 24.
A mob scene greeted Upton at the plate. An avid FSU football fan, Upton did a little dance, ala Deion Sanders, while covering the final 10 feet of his journey around the bases.
"We've been missing a little bit of the magic this year and it doesn't get much more magical than that moment right there," manager Joe Maddon said. "Like I've been saying, if you believe you can do it, you can. If you believe you cannot, you cannot. So we've done it before. We just did it again tonight. I want to believe that's who we are."
David Price started for the Rays hunting his 19th win of the season and Clay Buchholz started for the Red Sox looking for his 12th win of a solid season. And, as forecast, hits were tough to come by.
Considered by some to be the favorite to win the AL Cy Young Award, Price offered a preview of things to come when he shattered the bat of Dustin Pedroia, the game's second hitter.
Price nicely dodged the damaged timber while Keppinger scooped up the ball near second and threw to first.
That would be the first of three bats that Price shattered, and the goose eggs mounted on the scoreboard for both sides, as Buchholz proved equally tough.
Buchholz "was really that good," Maddon said. "It's so annoying to see him that good. He was that good. He had everything working -- two-seamer underneath, cutter going the other way, curveball when he wanted, changeup to both sides of the plate. He was on top of his game. He was definitely as good as he can be tonight. He truly was."
After five scoreless frames, the Red Sox got busy in the sixth.
Jose Iglesias singled to lead off the inning. Price struck out Jacoby Ellsbury for the first out before Pedroia hit a ball to deep right field that Matt Joyce hauled in with a nice over-the-shoulder grab.
Cody Ross then stepped to the plate with two outs and Price uncorked a wild pitch that allowed Iglesias to advance to second. Ross doubled to left-center field to drive home Iglesias, and Ryan Lavarnway followed with a single through the middle of the infield that glanced off shortstop Ben Zobrist's glove. Ross raced home and the Red Sox were up 2-0.
Mauro Gomez tripled home a run for the Red Sox in the eighth, Zobrist drove home the Rays' first run in the bottom half of the inning with a sacrifice fly, then Iglesias hit his first career home run in the ninth to give Boston a 4-1 advantage.
Price and Buchholz each earned a no-decision.
While the Rays' win fed their souls Thursday night, there is much work left to do with just 12 games remaining on their schedule, a fact Upton acknowledged.
"It's a victory right now," Upton said. "We still have some games left. If something happens like that at the end of the season, I'll say it's magic. But right now I'll just say that's a win. We've got [12 games left]. Have to try and win as many of them as possible."