TORONTO — Since Aug. 1, when the Yankees sold off some of their best players, Joe Girardi said his club wasn’t giving in. “We’re going to keep fighting,” he has said once, twice, 50 times or more.

This was quite literally the case last night in a 7-5 victory over the Blue Jays.

There were two bench-clearing incidents in the first two innings, which led to four Yankees ejections, homers by Mark Teixeira and Aaron Hicks in a wild five-run ninth, and a Blue Jays rally in the bottom half, when the Bombers barely hung on.

“Was that fun to watch or what?” said a bubbly Teixeira, who punctuated his homer off Jason Grilli with a Jose Bautista-caliber bat flip and some trash talk toward the pitcher from the dugout as the inning dragged on. “We’re all entertainers, aren’t we?”

Indeed.

The Yankees (80-76) trailed 3-1 entering the eighth and 3-2 in the ninth before Teixeira hit a solo shot and Hicks hit a two-run homer off Grilli. They avoided a four-game sweep to finish this trip 3-8.

advertisement | advertise on newsday

Jacoby Ellsbury added an RBI single and Gary Sanchez had a sacrifice fly in the inning to make it 7-3. But the bottom half was far from easy.

The struggling Dellin Betances walked Justin Smoak and misplayed a bunt single by Kevin Pillar to start the ninth. Betances threw a wild pitch before walking Darwin Barney to load the bases.

Lefty Tommy Layne got Josh Donaldson to fly to right but walked Edwin Encarnacion to force in a run to make it 7-4. Dioner Navarro blooped a single to right-center that made it 7-5. Russell Martin topped one in front of the plate that Layne fielded, and then with a dive beat Barney to the plate. With the bases still loaded, Layne got Troy Tulowitzki to fly to left, where Brett Gardner made a sliding catch in foul ground to end it.

“I put him (Layne) in a really bad situation,” said Betances, who has allowed at least one run in five of his last eight outings and said “mechanically” he feels off. “Thank God Tommy picked me up.”

The scuffles led to the ejection of Girardi, bench coach Rob Thomson, pitching coach Larry Rothschild and starting pitcher Luis Severino. Third-base coach Joe Espada took over for Girardi, who was still steamed at the umpires afterward, saying they did a “poor job.”

Yankees videos

It started in the first inning when a wild Severino — he walked two in a 32-pitch first — hit Donaldson on the left elbow. The Blue Jays, who were angry Friday night when Bautista was plunked in the ninth by Ben Heller, chirped in the dugout.

J.A. Happ, who allowed two runs (one earned) in 7 1/3 innings, threw behind Chase Headley to lead off the second, then hit Headley near his left hip with his second pitch. Headley slammed his bat and plate umpire Todd Tichenor warned the benches, both of which slowly emptied onto the field. During the scrum, Girardi was ejected.

“Once Happ takes one shot at Headley and throws it behind and there’s no warning, I have a problem with that,” Girardi said.

Said Headley: “Usually when you throw one behind somebody, then you hit them with the next pitch, you’re out of the game.”

It got uglier in the bottom half of the inning, when Severino hit Smoak on the left foot with his second pitch, causing the benches to empty far more forcefully. Severino, who gave a “bring it on” gesture to Smoak and a charging Kevin Pillar, was ejected, as was Thomson and eventually Rothschild, who was angry because Happ stayed in. Yankees rookie Tyler Austin had a nick under his left eye, the result of, he theorized, an opposing player’s fingernail.

advertisement | advertise on newsday

“Our team has been fighting all year,” Teixeira said. “We’re probably not going to make the playoffs, so we’re just going to enjoy ourselves the rest of the year, keep fighting. We had fun tonight.”