OAKLAND, Calif. (AP) -- With an opportunity at a second consecutive shutout, Athletics manager Bob Melvin had no problem sending Daniel Mengden out for the ninth inning.
Three batters later Mengden was in the dugout, his scoreless streak over but a much-needed win for the A's all but wrapped up.
Mengden allowed three runs over eight innings and Oakland beat the Tampa Bay Rays 7-3 on Thursday to avoid a four-game sweep.
"I knew my leash wasn't going to be very long," Mengden said. "He let me stay out there as long as I figured I would. Just comes down to not executing pitches that last inning. Did it for eight innings, but didn't execute for nine."
Mengden (6-4) was dominant most of the game against Tampa Bay. He gave up six hits, struck out five and extended his scoreless streak to a career-high 25 innings before giving up three straight hits, including a two-run double by Wilson Ramos in the ninth.
It's the longest scoreless streak by any A's pitcher since former closer Sean Doolittle went 26 1/3 innings in 2014. Mengden's run is also the best by an Oakland starting pitcher since Cory Lidle's 32-inning streak in 2002.
In six May starts this season, Mengden has a 1.51 ERA.
"This has been Daniel's month," Melvin said. "He's been absolutely terrific. When you have four pitches it's tough for hitters to think along with you, and he uses all four of those pitches. You're seeing very few balls barreled up."
Josh Lucas replaced Mengden and retired two hitters. Blake Treinen got Johnny Field to pop out to shortstop for his 13th save.
Matt Olson, Matt Chapman and Matt Joyce all homered, providing some much-needed punch to an offense that had sputtered since their leading home run hitter Khris Davis went on the disabled list 10 days earlier.
Davis was activated before the game and doubled and scored as part of a three-run second inning to help Oakland end a three-game losing streak.
"I don't think that's coincidence at all," A's shortstop Chad Pinder said. "He's got that much influence on our lineup. It changes how other teams go about pitching us. With him in the middle of the lineup, the guy's proven to be our best run-producer by far."
Joey Wendle had three hits for Tampa Bay.
The Rays had won five straight and outscored the A's 11-3 through the first three games of the series before getting shut down by Mengden.
"(Mengden) made it really challenging," Rays manager Kevin Cash said. "He pitched kind of like the line showed. Our guys just didn't have too many opportunities to square balls up."
Olson and Chapman hit solo home runs in the seventh off Ryan Yarbrough. Joyce added a two-run shot in the eighth off Vidal Nuno.
Ryne Stanek (1-1) started for Tampa Bay and retired four batters in his second major league start. Stanek earned his first career win Monday in relief.
WHAT AN ENDING
Pinder preserved the win when he made an over-the-shoulder catch on Field's pop-up in the ninth. The ball bounced out of Pinder's glove, but he caught it bare-handed for the final out.
"I told him he can use his glove too," Melvin said. "Doesn't have to make it that dramatic. It was a nice play."
RAYS DEAL MINOR LEAGUE CATCHER
The Rays traded minor league catcher Curt Casali to the Cincinnati Reds for cash. Casali batted .199 with 19 home runs and 49 RBIs in 161 games over four seasons with the Rays.
The 29-year-old was hitting .274 with four home runs and 20 RBIs this year for Triple-A Durham.
Rays: Right fielder Carlos Gomez (groin) was held out of the starting lineup. Gomez tweaked the injury legging out a triple Wednesday night. ... Third baseman Matt Duffy was given the day off.
Athletics: Right-hander Santiago Casilla (shoulder strain) has been playing catch and the team expects to make a decision in the next few days when to send the veteran reliever on a rehab assignment. ... RHP Carlos Ramirez was optioned to Triple-A Nashville.
Rays: The team hasn't announced who will start Friday's series opener in Seattle, although manager Kevin Cash is leaning toward having reliever Sergio Romo go. Romo made four starts in a nine-day period from May 19 to 27.
Athletics: RHP Frankie Montas (1-0, 1.50 ERA) makes his second start for Oakland in Kansas City on Friday. Montas set career highs for innings pitched (six) and strikeouts (seven) in his A's debut against Arizona last Sunday.
More AP baseball: apnews.com/tag/MLBbaseball