ST. PETERSBURG, Fla. — Elvis Andrus picked a nice time to break out of a hitting funk.

The Texas shortstop drove in his first runs since July 2, smacking a solo homer to stop an 0-for-16 skid and then snapping a 10th-inning tie with a two-out infield single that gave the Rangers a 4-3 victory over the Tampa Bay Rays on Friday night.

"It was a resilient win for us," Andrus said after Texas rallied from a 3-1 deficit in the ninth and stopped a five-game losing streak. "Even when we were down, we still feel that we were in the game. ... It was really a team effort right there top to bottom. Hopefully we can carry that momentum."

Andrus, who homered in the first inning, hit a sharp grounder off Brad Boxberger (2-1) that forced Evan Longoria to make a diving stop. Pinch runner Delino DeShields scored when the third baseman was unable to complete the throw to first base for the third out.

Alex Claudio (2-0) pitched two innings in relief of Yu Darvish to get the win. The left-hander gave up a leadoff single to Steven Souza Jr. in the 10th, but avoided further damage by getting Adeiny Hechavarria to bunt into a double play and Mallex Smith to fly out.

Rays starter Alex Cobb took a three-hitter and two-run lead into the ninth, but couldn't finish off the Rangers, who erased their deficit with Joey Gallo's double and Shin-Soo Choo's 14th homer within a three-pitch span.

"Probably the most upset and angry I've been walking off the mound in a long time," said Cobb, who was seeking his first complete game in four years. "I was given an opportunity ... to go shut the door and didn't execute a few pitches in a row. It turned south quick."

Other than allowing a trio of solo homers, Darvish was outstanding for the Rangers.

The All-Star right-hander yielded five hits, walked one and struck out 12 over eight innings, yet was in line to drop a career-high fifth consecutive decision before the Rangers rallied against Cobb in the ninth.

The Rays built their lead on homers by Brad Miller, Corey Dickerson and Smith, whose eighth-inning shot made it 3-1.

Things shifted quickly when manager Kevin Cash decided against turning the game over to closer Alex Colome, who leads the AL with 26 saves, to begin the ninth.

"I was confident the way he was throwing the ball," Cash said of Cobb. "I had the confidence for him to go back out there and get three more outs. No slight to anybody in the bullpen, especially Alex Colome."

TRAINER'S ROOM

Rangers: Manager Jeff Banister said Joey Gallo, who has been slowed by a sore left hamstring, is not ready to play on a regular basis in the outfield. Gallo is playing first base and DH.

Rays: Souza, who injured his left hip sliding Wednesday, was out of the lineup but pinch-hit in the 10th. ... CF Kevin Kiermaier, who's missed 35 games with a broken right hip, says his rehab has been "pretty much pain free" and expects to return in early to mid-August.

BACK-TO-BACK LOSSES

The Rays are 4-3 since the All-Star break and have dropped two straight for the first time since June 28-29 at Pittsburgh. They fell to 44-2 when leading after eight innings.

BELTRE WATCH

Rangers 3B Adrian Beltre went 1-for-4, singling in the ninth inning off Colome to move ahead of Sam Rice for 31st on the career hits list with 2,986.

DOUBLE-DIGIT K's

Darvish struck out 10 or more in a game for the fourth time this season, 32nd overall. That's two shy of Hall of Famer Nolan Ryan's franchise record of 34 double-digit strikeout games.

NICE CROWD

Attendance was announced as 24,461, up nearly 9,000 from Tampa Bay's average home attendance of 15,681, which ranks last in the majors. Friday was the first time the Rays played a home game after the All-Star break while in playoff contention since Sept. 23, 2013. They went on win a Game 163 tiebreaker to claim a wild-card berth that season.

UP NEXT

Rangers RHP Andrew Cashner (4-8), who's 1-1 with a 1.98 ERA in two starts this month, goes against Rays RHP Chris Archer (7-5) Saturday night. Archer has worked at least six innings in 11 consecutive starts, the longest streak of his career.

___

More AP baseball: https://apnews.com/tag/MLBbaseball