Anthony Swarzak, right, hands the ball to manager Joe Girardi...

Anthony Swarzak, right, hands the ball to manager Joe Girardi during Toronto's four-run sixth inning on the way the Blue Jays' 12-6 victory at Yankee Stadium on Tuesday, Aug. 16, 2016. Credit: Jim McIsaac

Blame it on the rain. And an epic bullpen meltdown.

A 42-minute rain delay at Yankee Stadium on Tuesday night cost Yankees starter Michael Pineda, who had thrown five shutout innings and just 68 pitches and exited with a six-run lead.

No worries, right?

Except the Blue Jays roared back by scoring 12 times against the Yankees’ bullpen — four in the sixth and eight in the eighth — en route to a stunning 12-6 victory.

Russell Martin’s second home run of the game, a two-run shot to right off Adam Warren in the eighth, gave Toronto its first lead at 8-6.

The Yankees had gone ahead 6-0 after five as rookie Gary Sanchez smashed two long home runs and drove in four runs in the first four innings. The 23-year-old Sanchez hit a solo shot into the Toronto bullpen in the second and followed that up in the fourth with a towering three-run homer to the second deck in left.

Both of Sanchez’s home runs were against righthander Marco Estrada. Sanchez (3-for-4), who also had an infield hit, is 16-for-47 (.340) with four home runs and 10 RBIs.

Sanchez’s second shot was a true rainmaker. After the ball came down, the skies darkened and a rain delay began after the top of the fifth with the Yankees leading 5-0. When play resumed, the Yankees added another run on Didi Gregorius’ single in the fifth.

But the delay cost the Yankees the services of Pineda, who was cruising. He had given up four hits, walked none and struck out two.

The Yankees are extra cautious with Pineda, who missed 2½ seasons because of shoulder surgery. He said he wanted to stay in the game and even kept warm by throwing 15 pitches in the indoor batting cage, but it was a no-go for manager Joe Girardi.

“It was unfortunate because Michael was really good,” Girardi said. “Gosh, I would have loved to send him out there, but with what he went through with that shoulder, we just felt that we couldn’t do it. It was frustrating. I was hoping it would be a quicker rain delay . . . It’s risky for him and it’s not a risk that we want to take. He’s important to us.”

Said Pineda: “I said, ‘I feel pretty good and I’m ready for pitching.’ But they try to take care of me a little bit because they know I sat down for like 45 minutes and they didn’t want something bad to happen to me. They said, ‘Take it easy.’ I really wanted to continue pitching.”

Anthony Swarzak came in and allowed four runs on four hits in the sixth, including back-to-back home runs to Troy Tulo witzki (a two-run shot) and Martin.

In the eighth, Warren (1-1) walked leadoff batter Josh Donaldson on 3-and-2 after a 12-pitch battle. Edwin Encarnacion followed with a two-run laser to left to tie it at 6. One out later, Tulowitzki singled and Martin, the former Yankee, gave the Blue Jays the lead with his 12th home run.

The four runs were the first runs Warren has given up since he rejoined the Yankees in a trade July 25. He said the Donaldson at-bat took a lot out of him.

“He kept fouling off good pitches,” Warren said. “It was a tough at-bat. You want to try to get the first guy out. When he goes that deep, hot night, you’re working hard, it wears you down a little bit. Demoralizing a little bit when you walk him.”

Toronto added four more against Chasen Shreve, who did not retire any of the four batters he faced, and Blake Parker. The Blue Jays sent 13 men to the plate.

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME