BALTIMORE -- David Price gave up 10 hits, barely made it out of the fifth inning and was admittedly exhausted after walking off the mound for the last time.
Not a great combination for success, yet the reigning AL Cy Young winner still found a way to beat the Baltimore Orioles.
Joyce hit a two-run drive in the fourth to break a tie and push the Rays toward their fifth win in six games. Tampa Bay moved within a half-game of the first-place Red Sox in the AL East, pending Boston's late game in San Francisco.
Price (7-5) was effective when it counted. He struck out six and allowed only two runs, as Baltimore went 2 for 11 with runners in scoring position and stranded 10 against the left-hander.
"That's why he's one of the best pitchers in the game. He knows how to get out of jams like that," Orioles center fielder Adam Jones said. "When he needs a strikeout, he knows how to get it."
Price seemed relieved to survive.
"That's the most draining it has been in a while," he said. "This (Baltimore) team is just, they're tough. That's why they're in the position they're in right now. ... We made some pitches when we needed to, had some hard hit balls at some guys. You've got to have that good fortune sometimes."
Price has won four straight decisions since July 12.
"You have to give David credit," manager Joe Maddon said. "David did not have his best night, but nevertheless ... I really, really appreciated his effort."
So did Price's teammates.
"David didn't have his best stuff tonight, and he did a great job battling, really giving us a chance to win," Joyce said.
Fernando Rodney, the fourth Tampa Bay reliever, worked the ninth for his 28th save.
Baltimore starter Chris Tillman (14-4) gave up four runs and five hits in six innings. It was his first loss in seven starts since July 6.
Matt Wieters had three hits and a home run for the Orioles, who fell five games behind Boston. Baltimore outhit Tampa Bay 15-10 but stranded 15 and went 2 for 14 with runners in scoring position.
"We got a good pitcher out of the game in the fifth inning and put a lot of good at-bats up against Price and just couldn't quite break it open," Wieters said.
Tampa Bay went up 4-2 in the fourth when Joyce hit his 16th home run after Yunel Escobar drew a one-out walk. In the Baltimore half, Manny Machado and Chris Davis struck out with runners at the corners.
Price worked out of trouble in the fifth, using his 99th and final pitch to retire Steve Pearce on a sharp grounder with two outs and the bases loaded.
"You've got to have those line drives at guys, you've got to have guys making good plays in the field, and that's what we did tonight," Price said.
Wieters homered off Joel Peralta leading off the seventh, but Baltimore left runners at first and third.
Perhaps taking a cue from the Orioles, Tampa Bay loaded the bases with no outs in the eighth but did not score. In the bottom half, Baltimore wasted a one-out double by Davis.
Longoria put the Rays up 1-0 in the first inning with his 25th home run, the second in two days. He has 11 extra-base hits in his last 12 games, including four homers.
Singles by Escobar, Joyce and No. 9 hitter Kelly Johnson made it 2-0 in the second.
In the bottom half, Danny Valencia got the last of three straight Baltimore hits, an RBI double. Valencia, recalled from Triple-A Norfolk before the game, went 2 for 2 with a walk against Price and is 9 for 12 lifetime against the lefty.
The Orioles got three more hits in the third, including a run-scoring double off the center-field wall by Wieters to knot the score at 2. But Baltimore left two runners in scoring position for the second inning in a row.
The game took 3 hours, 56 minutes. ... The Rays activated Desmond Jennings (finger) from the disabled list and optioned RHP Brandon Gomes to Triple-A Durham. Jennings started atop the lineup and went 1 for 4. ... J.J. Hardy, who turned 31 on Monday, started at shortstop for Baltimore after missing two games with back spasms. ... Alex Cobb (7-2) starts for the Rays on Tuesday night against Baltimore RHP Miguel Gonzalez, who's 5-1 at home. ... Price walked only three of 258 batters over his previous nine starts. In this one, he walked two of 27.
New York Yankees trade 1B Mike Ford to Tampa Bay Rays for $100,000
First baseman Mike Ford was traded by the New York Yankees to the Tampa Bay Rays on Thursday for $100,000 and a player to be named.
The State of Baseball: MLB's biggest challenges for 2021 and far beyond
From rising strikeout totals and unwritten rules debates to connecting with a new generation of fans and a looming labor battle, baseball is at a crossroads.
Fantasy baseball prospect watch: Hot takes at the hot corner
Eric Karabell refreshes his weekly analysis of some of the top fantasy-relevant players taking their first action in the majors with a look at the future stars of third base.
Fantasy baseball forecaster: Team hitting ratings
Stay ahead of the game and optimize your fantasy baseball hitters with our forecaster, which provides a rolling 10-day outlook of every team's hitting matchups as well as the potential for stolen bases.
Fantasy baseball forecaster: Pitcher projections for the next 10 days
Keep up to date on who is pitching -- and how well they're expected to do -- with our forecaster, which provides a rolling 10-day outlook of every team's probable starting pitchers with game score projections.
The most fun you can have at a ballpark? What MLB could learn from the Savannah Bananas
They're hilarious. They're social media favorites. They're pushing the envelope of what baseball can be in 2021 and beyond.