MINNEAPOLIS (AP) — Yandy Díaz hit a sacrifice fly for Tampa Bay in the 18th inning to break a tie that lasted since the second, and the Rays finally pulled away from Minnesota for a 5-2 victory on Thursday to avoid being swept in a series by the Twins for the first time in 13 years.

Ryan Yarbrough (7-3), the eighth reliever and the 22nd player used by the Rays during the game that lasted 5:42 after rain delayed the first pitch by 57 minutes, threw three scoreless innings for the victory.

After the first eight relievers for the Twins allowed just two hits over a combined 10 innings, Ryne Harper (3-1) faltered in the 18th while pitching for the third straight game and the sixth time in the past 10 days.

The Rays loaded the bases with nobody out, just as they did in the 10th against Blake Parker when they failed to score. Díaz hit a medium-depth fly ball with one out to left fielder Luis Arraez, whose strong throw was a little too far up the first-base line for catcher Jason Castro to catch and make the tag before Brandon Lowe's left hand grazed the plate on his head-first slide.

Willy Adames and Ji-Man Choi followed with RBI singles to give the Rays some insurance and salvage a 3-7 record from this three-time zone road trip. Just 13 days ago, they led the American League East by a half-game over the New York Yankees. Now they're 6½ games back.

Rays pitchers set a franchise record with 22 strikeouts. This matched their longest game in history, innings-wise, and this was also the most innings played in Target Field's 10-season history. The Twins beat the Boston Red Sox in 17 innings just last week.

The Twins turned to starter Kyle Gibson (9-4) for the 17th inning, his first relief appearance in 170 career games.

WAY BACK WHEN

Ryne Stanek made his major league-leading 23rd start for the Rays in their trendsetting opener role, falling behind 2-0 in the first of his two innings. Arraez had the third hit of the frame for the Twins, a sharp two-out single to right field that prompted third base coach Tony Diaz to wave Nelson Cruz home.

The throw by Guillermo Heredia would've beaten the 38-year-old designated hitter by a long way, but the ball skipped past catcher Mike Zunino for an error on Heredia as Cruz safely reached the plate.

The Twins, who lead the major leagues in runs and several other hitting categories, left starter Martín Pérez hanging after he allowed only three hits over seven stellar innings.

After allowing consecutive two-out RBIs in the second that tied the game, a double by Michael Brosseau in his first major league start and a single by Heredia, Pérez finished his afternoon by retiring 16 consecutive batters. Pérez was 0-2 with a 7.50 ERA in his previous five turns.

The Twins, who were missing three regulars from their lineup to injuries, went without a home run in two straight games for the first time since May 30-31, also against the Rays.

The Rays, who improved to just 11-16 since beating the Twins 14-3 on May 30, were further thinned when center fielder Kevin Kiermaier departed with tightness in his lower right leg in the second inning.

TRAINER'S ROOM

Rays: 3B Yandy Diaz was reinstated from the injured list after the minimum 10-day stay and placed in the cleanup spot in the batting order. To make room on the roster, RHP Hunter Wood, who has a 2.24 ERA in 24 innings, was sent to Triple-A for the third time this month.

Twins: The multi-positional Willians Astudillo, who has spent most of his time behind the plate, was placed on the 10-day injured list with a strained left oblique. He said he initially hurt the muscle while making a catch against the wall in RF on Tuesday, then aggravated it while swinging in his last at-bat on Wednesday. OF LaMonte Wade was recalled from Triple-A to fill his spot, the first time in the major leagues for the ninth-round draft pick in 2015.

UP NEXT

Rays: The starting pitcher for the series opener on Friday night against Texas has yet to be determined. RHP Lance Lynn (9-4, 4.32 ERA) takes the mound for the Rangers, as the Rays start a 10-game homestand that lasts until the All-Star break.

Twins: RHP Jose Berrios (8-3, 2.84 ERA) will take his 17th turn of the season in Chicago on Friday night, opening a three-game series. Berrios has a 1.63 ERA in four starts this month. The White Sox were waiting to announce their starting pitcher.

More From KROC-AM