SEATTLE — Two outs in the ninth inning, trailing by three, a runner on first base but facing a closer who hadn't given up an earned run all season. And still, Willi Castro believed.

"When you're positive, a lot of good things happen," Castro said. "And that happened."

What happened?

"One of the greatest wins that we've had," Twins manager Rocco Baldelli crowed, as his team loudly celebrated its 18th victory of the month, 12-6 over the Mariners on Friday at T-Mobile Park. "One of the best wins that I can remember."

And certainly one of the most improbable, considering the Twins trailed 4-0 after only five Mariners had batted, and still were down 6-3 in the ninth.

But as the fireworks-night crowd of 31,614 stood and cheered, Seattle closer Andrés Muñoz, just one out away from his MLB-leading 18th save, served up a 98-mph fastball across the heart of the plate. Castro drove it 410 feet over the fence in right-center, his second home run of the night. "When I saw on TV he hadn't allowed a run, I told myself I would take that from him," Castro said. "That's the great thing about being positive."

It got even better. Byron Buxton followed with a single, immediately stole second base, and scored when Trevor Larnach lined a single up the middle, tying the score for the first time all night and stunning the crowd into silence.

The 10th inning was the chef's kiss on a spectacular rally. Carlos Correa, booed all night by the rowdy crowd, launched Casey Legumina's first pitch of the inning into the Mariners bullpen, scoring courtesy runner DaShawn Keirsey Jr. ahead of him. From there, the Twins piled four more runs on the Mariners, who allowed a seven-run 10th to the Nationals just one night earlier.

Brooks Lee followed Correa's homer with a single, and two-out walks to Royce Lewis and Castro loaded the bases for Buxton, playing his first game since suffering a concussion two weeks ago. Buxton singled home two, Larnach doubled home two more with his fourth hit of the night, and the fireworks-night crowd booed their team.

"We were fired up in the dugout. It was as much fun as we've had playing baseball this year," Correa said. "I was very happy that everybody pretty much contributed to the win today. It was a special game for sure."

Oddly, one of the biggest contributors was the guy who allowed four of the first five batters he faced to score, on two quick singles and then back-to-back home runs by Cal Raleigh, the who's-he name between Shohei Ohtani and Aaron Judge in the list of MLB home run leaders, and Randy Arozarena.

"I wouldn't have believed it, I'll say that," Zebby Matthews said after pitching a career-high seven innings — the last six of them masterful. "The first inning, if I could take it back, I'd love to. But I battled."

That he did, and so did his teammates. The 25-year-old righthander didn't allow another Mariners batter to reach second base and didn't allow a hit to the last 15 batters he faced, becoming the first "fifth starter" the Twins have used this season to pitch more than five innings. So impressed were Baldelli and pitching coach Pete Maki, Matthews was sent out for the seventh inning, even after the Twins closed the gap to just one run. He responded by retiring Seattle in order on two routine grounders and a strikeout.

"Zebby was on a tremendous roll. That's as good as he's thrown the ball in the big leagues," Baldelli said. "Mentally, he was gaining confidence as the game went on."

Meanwhile, the Twins offense, so often sluggish this year, gathered steam as the night went on. Larnach homered off Seattle starter Bryan Woo in the fourth inning, Ryan Jeffers followed with a double, and Lee drove him in from third with a groundout.

BOXSCORE: Twins 12, Seattle 6 (10)

MLB standings

Castro added his first home run of the night, which just cleared right fielder Leody Taveras' glove, off Woo in the seventh.

But Raleigh — a close friend of Matthews, who grew up in the same small North Carolina town — widened Seattle's lead to 6-3 with another homer in the eighth off Cole Sands, his former teammate at Florida State. That blow seemed to decide the game — in everyone's minds except the Twins'.

"The text chain [between Raleigh and his two victims] has already started," Sands said.

We know who had the last laugh in that conversation.