ST. PETERSBURG, Fla. — Wade Miley missed with a slider and Matt Barnes missed with a couple of fastballs. The Tampa Bay Rays hit all three of them for home runs Saturday and beat the Boston Red Sox, 4-1.

Matt Andriese and three relievers combined on a three-hitter for the Rays, who scored first on Jake Elmore’s two-out, two-strike home run off Miley with a man on third base in the fifth.

“I was trying to bounce it and just left it up,” said Miley, who entered the game 3-0 in three starts against the Rays. “I thought I had him in a pretty good situation, just didn’t execute the pitch.”

Elmore’s homer, his second of the year, dropped over the short wall in the left-field corner.

“When I hit it I didn’t even think home run,” Elmore said. “I just worried it was going foul. I thought I kept it fair and thankfully I did.”

Andriese (3-2) retired his first 11 batters before allowing his lone baserunner, coming on a two-out single in the fourth by Xander Bogaerts. Andriese struck out five in a career-high six innings for the Rays.

“On a day where Andriese threw a lot of fastballs at us, for a lot of strikes, we never got anything going offensively,” said Boston Manager John Farrell.

Miley (7-7) gave up two runs, five hits, two walks and struck out eight over 61/3 innings for Boston. He had thrown 16 scoreless innings at Tropicana Field and didn’t have the sense the two-run homer would be enough to beat him.

“You never feel like that with our offense,” Miley said. “That guy (Andriese) did a really good job of mixing up his pitches and making pitches when he needed to, but with this offense, we can open up at any time and put a big number up.”

But the Red Sox played a second straight game without the injured Hanley Ramirez and Dustin Pedroia.

Their only run came on Alejandro De Aza’s home run off reliever Kevin Jepsen in the eight. Brad Boxberger allowed a single in a scoreless ninth for his 20th save.

Rene Rivera and Evan Longoria added late Tampa Bay homers off Barnes, who was recalled from Triple-A Pawtucket before the game.

The loss dropped the Red Sox to 12-24 against AL East rivals.

Tampa Bay tied a team record with its 10th consecutive win against a left-handed starter. The Rays also did it in 2004.

Mookie Betts of Boston had his career-best 13-game hitting streak end after going 0 for 4. It was the longest streak by a Red Sox player since Jacoby Ellsbury had a 19-game streak in 2013.

NOTES: Barnes pitched the final 12/3 innings after flying from Pawtucket on Saturday morning and arriving at the ballpark at 1 p.m. “It’s been a long day but that’s part of the profession,” he said. “You’ve still got to go out there and put up zeroes.” … Ramirez (left hand), who missed his third straight game, isn’t ready to swing a bat. … Rays pitcher Jake Odorizzi (oblique) threw 51 pitches in batting practice and could make a minor league start Thursday.