ST. PETERSBURG, Fla. — Willy Adames' winning drive landed high in the left-field seats. According to Statcast, it measured 434 feet, the longest of the rookie's five homers.

"That's all I've got," Adames said. "I went for it and I got it."

Big time.

Adames' solo homer with two out in the ninth inning lifted the Tampa Bay Rays to a 4-3 victory over the Baltimore Orioles on Tuesday night.

Adames connected against Miguel Castro (2-6). Sergio Romo (2-2) got the win after retiring two batters in the ninth, helping Tampa Bay break a three-game losing streak.

Tim Beckham and Trey Mancini homered for Baltimore, and Alex Cobb pitched seven strong innings.

Cobb, attempting to win consecutive starts for the first time with the Orioles, gave up only two hits after the first inning and retired his last 10 batters against his former team.

"Every time out there I walk off the mound and I feel like that I'm that much closer to regaining the form that I've been looking for," said Cobb, who lost his first three starts against the Rays.

Cobb is 3-14 in his first season with Baltimore. But he has allowed one earned run in three of his four starts since the All-Star break.

Cobb left with a 3-1 lead, but the Rays tied it in the eighth without getting a hit. Three walks and a wild pitch by Evan Phillips and a throwing error on first baseman Chris Davis helped the Rays score two unearned runs.

Jake Bauers drove in the only run off Cobb with a third straight single in the first inning, following hits by Mallex Smith and Matt Duffy.

Tyler Glasnow struck out nine in four innings in his second start for the Rays after being acquired from Pittsburgh on July 31. He was lifted after 61 pitches.

"They're trying to build me up and not rush me, and that's probably a better decision than going out there and rushing things," Glasnow said.

One of the two hits off Glasnow was a homer by Beckham, his fifth of the season.

Mancini's 16th homer came off Jaime Schultz and put the Orioles ahead 2-1 in the fifth.

Mark Trumbo drove in another Baltimore run with a single in the sixth, extending his hitting streak to nine games.

A ONE-RUN KIND OF SEASON

The Rays' last four games (including three losses to the Chicago White Sox) have been decided by one run. They have played a major league-leading 47 one-run games, losing 26 of them.

TRAINER'S ROOM

Orioles: Davis was back in the lineup after missing two games. Manager Buck Showalter said the slugger sat out because he was "banged up." ... OF Craig Gentry (broken left rib) started a rehab assignment at Double-A Bowie.

Rays: INF Daniel Robertson had what is expected to be season-ending surgery to repair a torn left thumb ligament. He was hurt Saturday sliding into second base on a double. ... Reliever Chaz Roe (left knee) could start a rehab assignment Thursday.

UP NEXT

Tampa Bay will start reliever Ryne Stanek (1-3) and have left-hander Jalen Beeks (1-1) follow Wednesday night against Orioles right-hander Andrew Cashner (3-10). Cashner's 15-5 win over the Rays on July 27 is his only win since May 21.