OAKLAND, Calif. -- Matt Chapman was thinking slider, and he guessed right.
Chapman's 17th homer and second game-ender came on a 1-0 slider from Diego Castillo (1-5), handed his first blown save in eight chances.
"I knew he didn't have very good command of that fastball so I thought that he was going to try to sneak a slider in there and I was ready to hit," Chapman said.
Frankie Montas pitched eight innings of one-run ball for the A's, who rallied for their fourth straight win and seventh in nine games after Tampa Bay took a 4-1 lead with three in the top of the ninth.
"It was awesome. I'm still kind of shaking from it," Chapman said. "That was so much fun and that was just a really big win for us and an important one for sure."
Tommy Pham homered in the sixth for the Rays, who lost their fourth consecutive game and eighth in 10.
Robbie Grossman drew a leadoff walk from Castillo, and Jurickson Profar walked one out later. With two outs, Marcus Semien extended his hitting streak to 17 games with a run-scoring single before Chapman connected.
"It looked like (Chapman) had an approach where he was going to get a breaking ball, and he wasn't going to miss it," Rays manager Kevin Cash said.
Lou Trivino (3-5) got one out for the win. Profar hit a solo homer in the fifth to put the A's ahead.
Pham and Brandon Lowe drew consecutive walks from Oakland closer Blake Treinen to start the ninth. After a double steal, Avisail Garcia singled in the tiebreaking run and Ji-Man Choi followed with an RBI single.
Garcia scored on Willy Adames' sacrifice bunt to make it 4-1.
Rays starter Charlie Morton pitched 6 1/3 innings of four-hit ball. He gave up one run, struck out six and walked two.
Montas allowed four hits, struck out nine and walked none.
"I was feeling pretty good. I was able to command my fastball and my breaking pitches," he said.
Montas has struck out nine or more in three straight outings.
"I'm really not trying to strike out people," he said. "I'm just trying to get groundballs early. If I get two strikes, I try to put them away."
Profar's homer was just the seventh Morton has given up in 93 2/3 innings. ... Montas retired 18 of the last 19 batters he faced.
The Rays recalled RHP Austin Pruitt from Triple-A Durham and optioned LHP Adam Kolarek to their top farm club.
Rays: LHP Jose Alvarado threw a bullpen at the team's minor league complex in Port Charlotte, Florida. Alvarado was placed on the restricted list retroactive to June 2 after he went to his native Venezuela due to a family emergency. He isn't expected to go on a minor league rehab assignment. "Hopefully, we avoid that," Cash said. "Bullpens, maybe set up a (simulated) game, something like that. Obviously, the quicker the better. We need him. He would be a big boost for us when we get him back."
Athletics: Manager Bob Melvin missed the game due to a planned medical appointment to address neck and back pain. He is expected to return Friday. Bench coach Ryan Christenson took over as manager for the night.
Rays: Had not announced a starting pitcher for Friday.
Athletics: RHP Tanner Anderson (0-1, 3.27 ERA) threw 5 2/3 innings of three-hit ball in his first career start June 10 against the Rays. He gave up two runs.
More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports
Remember the buzz about the Nats trading Mad Max? Ancient history
When D.C. was down in the dumps, it seemed Washington might actually deal ace Max Scherzer. Now that the Nats have climbed back into contention, though, expect them to buy, not sell.
Buster's deadline deal of the day: Why Bucs should -- and shouldn't -- trade Felipe Vazquez
The All-Star closer might be the most coveted available player over the next 16 days. The Pirates should be prepared to do what it takes to close the right deal.
Olney: Indians should trade Bauer, Hand
Buster Olney suggests the Indians should trade Trevor Bauer and Brad Hand for their value despite the fact it might upset their fans.
Streaking Angels hope to have Trout in lineup vs. Astros
Mike Trout could be back in the lineup as soon as Tuesday when the Los Angeles Angels play the Houston Astros in the second game of the four-game series in Anaheim, Calif.
Crawford, Giants aim for more offense vs. Rockies
History-making shortstop Brandon Crawford gets a crack at a struggling rookie pitcher when the San Francisco Giants and Colorado Rockies continue a four-game series on Tuesday night in Denver.
Cards, Pirates streaking in opposite directions
After tossing seven scoreless innings Sunday afternoon, Adam Wainwright dared his fellow St. Louis Cardinals starting pitchers to match his feat. On Monday, Miles Mikolas answered the call and raised the bar even higher.