TORONTO — The Montreal Impact came to Toronto leaking losses and surrounded by a soap opera-like atmosphere. They leave with bragging rights, at least for one night, over the best team in Major League Soccer.

Ignacio Piatti and Anthony Jackson-Hamel each scored twice as the Impact ended their slump in spectacular fashion Wednesday in a wild 5-3 win that derailed, if only temporarily, Toronto FC's seemingly relentless march towards the Supporters' Shield.

Toronto striker Tosaint Ricketts made it interesting with goals in the 77th and 79th minutes as the desperate home side looked to claw its way back with the BMO Field crowd of 28,898 roaring it on.

"Tonight was massive," said Montreal coach Mauro Biello, who has heard it from the fans and his owner in recent days. "We fell into a little bit of a rough spell these last couple of weeks. We dropped some games at home.

"Tonight was important to forget about the standings, forget about the distractions. Focus on a game — us versus Toronto. The guys came out, they bounced back. They played with intensity, with quality and confidence."

Toronto (18-4-8) had not lost since July 1 when it dropped a 3-1 decision at FC Dallas. TFC came into the game unbeaten at home this season and on record pace as it chewed up MLS opposition.

But Montreal (11-12-6) was full value for the win, leading 2-0 after 12 minutes and 3-0 after 24. While Toronto may have the last laugh come the playoffs, it was a loss that the home side will long remember — Montreal payback for past indignities at the hands of TFC.

Marco Donadel also scored for Montreal, which came into the game six points out of the playoff picture. Toronto, missing three star players in Sebastian Giovinco, Jozy Altidore and Victor Vazquez, also got an own goal from Deian Boldor late in the first half.

Toronto made errors early, with defender Eriq Zavaleta having a rare off night.

"We looked a little bit uncomfortable at the start of the game," said Toronto coach Greg Vanney.

It was like saying Jabba the Hutt could do to lose a few pounds.

Toronto came into the match without Giovinco and Altidore, both injured, and star playmaker Vazquez on the bench after a slight fever. The three have a combined 35 goals and 27 assists.

With 12 other TFC players also scoring this season, there was offence available elsewhere. But it was the visiting side that showed its teeth early.

Montreal went ahead in the 10th minute on a freak goal that saw goalkeeper's Alex Bono's attempted clearance bounce off Piatti and back into the goal. The problem started when Zavaleta was unable to clear a Daniel Lovitz cross and the TFC defender's short backpass left Bono with few options.

Zavaleta was in the spotlight again in the 12th minute when he gave away the ball. It ended up with Donadel who launched a swerving rocket from well outside of the penalty box.

Piatti made it 3-0 in the 24th minute, taking advantage of a Zavaleta slip to make space and hammer a high ball home.

Trailing 3-1 at the half after a Deian Boldor own goal, Toronto saw the bottom fall out early in the second half with goals by Jackson-Hamel in the 47th and 51st minutes as its defence was carved open again and again.

"Uncharacteristic mistakes for this team this year," lamented Vanney. "It's like we brought them all out in one game."

Toronto came into the game with the second-stingiest defence, yielding just 26 goals in 29 games for 0.90 a game.

The Impact had lost four straight, a slide that started with a 2-1 defeat Aug. 27 at the hands of TFC. A 3-2 loss to Minnesota on a late goal last weekend prompted owner Joey Saputo to issue a statement to fans, asking for patience during an "extremely trying" season.

Undefeated in a club-record 11 games (8-0-3), Toronto was looking for its seventh straight win — tying the league record in the post-shootout era. Other than the MLS Cup final, which Toronto lost in a penalty shootout, Toronto had not lost a regular-season or playoff game at home since Oct. 1, 2016.

The Impact played three at the back, swarmed TFC captain Michael Bradley when he had the ball and pressured Toronto at the other end.

Vanney replaced Zavaleta in the 32nd minute with forward Ben Spencer. He said later it was a tactical move and not a statement on Zavaleta's play.

The game was reminiscent of the Eastern Conference final last November when the Impact raced into a 3-0 lead after 53 minutes in the first leg of a two-game series.

Altidore and Bradley answered back for Toronto in a 3-2 loss. Toronto went on to win the second leg 5-2 at home for a 7-5 aggregate win.

The comeback fell short Wednesday.

Toronto will move on, with lessons learned.

"The margins in this league are such that if you make mistakes, you can lose. And you can give up a lot of goals," said Vanney.

After a dream season as belle of the MLS ball, for this night TFC was reminded it was not the prettiest girl in school.

The last time Toronto gave up five goals in league play was a 5-0 loss to the Red Bulls on July 6, 2011. TFC lost 6-0 in Montreal in the Canadian Championship in 2013.

Follow @NeilMDavidson on Twitter