MINNEAPOLIS — The Twins had more than their share of chances to finally snap out of their five-game losing streak on Thursday. Michael Pineda threw seven shutout innings. Taylor Rogers nearly shut down the game-tying Boston rally — twice. They got gifted a second chance on a phantom foul call that kept an at-bat alive. Heck, they even laid down a successful sacrifice bunt.

In a chaotic game that featured a four-minute tornado siren delay and a seemingly endless stream of replay reviews, Luis Arraez finally helped the Twins punch through their offensive malaise and missed opportunities with a four-hit game, driving in a pair and scoring the winning run in the ninth as Minnesota avoided a sweep with Max Kepler’s RBI single sending the Twins to a 4-3, walk-off win over the Red Sox.

The highs of a dominant Pineda start and Arraez’s clutch two-run single in the second quickly vanished in the top of the eighth, when Alex Verdugo won a 10-pitch at-bat against Rogers and punched a game-tying, three-run double to tie things up. The Twins had their chance for an immediate answer by putting a pair in scoring position with one out — and failed to plate a run.

But they got one more shot in the ninth, and they took advantage. Arraez singled to right for his fourth hit of the game, Jorge Polanco followed with a hit-by-pitch, and two batters later, Kepler finally took the big swing the Twins needed, punching a bloop single into center that plated Arraez and, at last, ended Minnesota’s skid.