The loss snapped the Rays' two-game winning streak , moving the team to 2-2 on the current seven-game road trip and to 18-24 on the season.
Grant Balfour started the ninth for the Rays hoping to hold a 5-2 lead, and he struggled with his control, walking leadoff hitter Hank Conger, the eighth hitter in the Angels' order, along with the next hitter, Efren Navarro, the No. 9 hitter. Collin Cowgill followed with a single to score Conger.
Rays manager Joe Maddon made a bold move at that point by pulling Balfour -- against whom Trout was 0-for-6 with four strikeouts in his career -- in favor of Brad Boxberger.
"You know what, I'm worried about the team," Maddon said. "In that moment right there, based on what we've seen Boxy be able to do and that part of the order coming up. And if it had been different batters he'd walked instead of 8-9. That would have made it a little different. But 8-9 and then here comes 2-3-4. I didn't like it. I thought Boxy had a chance against these guys."
Boxberger entered the game to face Trout.
"Once the closer's in the game you expect the game to be over, but you always have to be ready for situations like this, and today it didn't work out," Boxberger said.
The count reached 1-1 when Boxberger threw Trout a changeup, and he clubbed his eighth home run of the season to give the Angels the walk-off win.
"It just trickled in and he was able to get to it," Boxberger said.
"I don't think I'd had success against Balfour before," Trout said. "I faced him a lot when he was with the A's. So I got the other guy."
Balfour lamented that he's been walking too many hitters.
"It just shows, walks kill you right there," Balfour said. "Overall, disappointing. I'm just not putting guys away, and walking guys ended up hurting me."
Balfour understood not getting the opportunity to face Trout.
"Hey, that's [Maddon's] decision and he went with it," Balfour said. "Personally, I'm disappointed by it because I always want to be out there until the end. I want to be out there and finish it. So any time I have to come out in the ninth inning is a bad thing for me. … A couple of walks there and a ground ball. I get it, I wasn't putting guys away, maybe. But that's the way it ended up."
Until the ninth-inning fallout, the Rays were perched to take home their third consecutive win, holding on to a three-run lead going to the ninth.
Erik Bedard started for the Rays and allowed no earned runs in 5 2/3 innings before leaving with a 4-2 lead. Brandon Gomes, Jake McGee and Joel Peralta then bridged the gap to Balfour.
Until the ninth inning Thursday night, Rays pitchers had not allowed an earned run in 25 consecutive innings, since an RBI groundout by Seattle's Robinson Cano against David Price in the first inning on Tuesday night.
Receiving a no-decision, Bedard was denied collecting a win in three consecutive starts for the first time since May 27-June 7, 2009.
On offense, Brandon Guyer went 2-for-3 with his first home run of the season and two RBIs. James Loney drove home two with a single, and Wil Myers drove in a run while going 2-for-4.
The loss handed the Rays their second walk-off loss of the season, and it was the second time in which they allowed at least four runs in the bottom of the ninth. The last time came on April 25 against the White Sox in Chicago when Balfour surrendered a grand slam to Jose Abreu in a 9-6 loss.
"We've had a couple [of tough losses in 2014]," Maddon said. "The one in Chicago was difficult. This one was also very difficult. You can't take too many mulligans like this. There's not that many available."