Already a longshot to advance before the opening kickoff against Toronto FC, a listless New York City FC crashed out of the MLS Cup playoffs Sunday night.

City surrendered three goals in the opening 30 minutes and suffering an embarrassing 5-0 loss in the second leg of the MLS Eastern Conference semifinals at Yankee Stadium. Toronto won the aggregate-goals series, 7-0.

The previous largest margin of victory in an MLS series was the LA Galaxy’s 5-0 series win over Real Salt Lake in 2014.

Sebastian Giovinco finished with a hat trick and former Red Bulls striker Jozy Altidore and Jonathan Osorio also tallied.

“We still have to work very hard to build up a strong team, because we have a gap between Toronto and ourselves,” City coach Patrick Vieira said. “The best team won. They deserve to go to the next round.

“When you don’t defend well as a team, you struggle. When you don’t defend well at all, you expose yourself and quality players like Giovinco express their talent.”

advertisement | advertise on newsday

The result ended a dreary day for both local MLS squads against Canadian clubs as the Red Bulls were eliminated from the postseason in a 2-1 home defeat to the Montreal Impact.

Toronto and Montreal will meet in the conference final for the right to play in the MLS Cup.

Former English international Frank Lampard probably has played his final match. He said he wants to pursue a coaching career. City’s two other high-profile players, striker David Villa — who wasn’t much of a factor Sunday night — and Andrea Pirlo, are expected to return.

On the first goal, Jack Harrison lost the ball to Altidore, who fed Giovinco. The Italian striker worked his way to the top of the box before powering a shot past goalkeeper Eirik Johansen.

“We were pushing to get the goal,” Toronto coach Greg Vanney said. “Two-nothing is a dangerous lead. Whoever gets the first one tilts the momentum your way.”

@NewsdaySports

It went from bad to worse as Frederic Brillant fouled Giovinco in the penalty area and the forward converted a penalty kick in the 20th minute.

Altidore latched onto a long pass and beat Maxime Chanot from the right side for a 3-0 advantage in the 30th minute. Osorio scored five minutes into the second half before Giovinco completed his hat-trick a minute into stoppage time.