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.