An ISIS-inspired terror plot targeting Times Square and the city’s subways — aimed at killing “thousands’’ and making “an ocean out of their blood’’ — has been foiled, authorities said Friday.

A trio of twisted wannabe terrorists, including a US citizen, were planning to strike the city over the summer of 2016, during the Islamic holy month of Ramadhan, officials said.

“NY Needs to fall. It’s a must,” said Talha Haroon, a 19-year-old US citizen living in Pakistan, that May, according to court documents.

Fortunately, Haroon made the proclamation to an undercover agent — and now all three men have been busted on terror charges, the feds said.

In the spring of 2016, Abdulrahman El Bahnasawy, a 19-year-old Canadian, and Haroon began planning the attack over messaging apps with the undercover posing as an ISIS supporter, according to the newly unsealed complaint.

They were getting help from Russell Salic, a 37-year-old living in the Philippines who wired money to the US to fund the attack, the papers said.

On May 1, 2016, El Bahnasawy allegedly sent the undercover agent maps of the Big Apple subway system — identifying lines they could blow up with explosives.

“The 2 subway routes we will blow up will be the purple one and the green one,” he told the undercover agent, referring to the No. 7 train and the Nos. 4, 5 and 6 trains from 103rd Street to 33rd Street, according to court documents.

A few days later, Haroon told the agent the subway was the “perfect” target — and they should gun down as many straphangers as possible, including “women or kids,” the complaint said.

“When we run out of bullets, we let the vests go off,” he said, according to prosecutors.

They also set their sights on Times Square.

“We seriously need a car bomb at times square. . Look at these crowds of people!” El Bahnasawy allegedly wrote to the undercover agent on May 12, 2016.

Haroon agreed that the Crossroads of the World was “a perfect spot to hit them” and suggested that the plan could include either a drive-by “or we surround the whole street and trap them and kill as many as possible,” the complaint said.

“I wanna kill . . . them in thousands” Haroon allegedly told the undercover. “We have to make a ocean out of their blood .. leave no one standing.”

It wasn’t just talk, according to the complaint.

El Bahnasawy, while in Canada, purchased an array of bomb-making materials for use in the planned attacks, including approximately 40 pounds of hydrogen peroxide, batteries, Christmas lights, thermometers, and aluminum foil — all of which could be used in making explosive devices, authorities said.

Meanwhile, in Pakistan, Haroon told the undercover agent that he had traveled to meet with an explosives expert “for the purpose of obtaining additional information to be used in building bombs for the planned NYC attacks,” the feds said.

Haroon told the undercover that they would need “perming cords,” or detonator cords, adding that El Bahnasawy was acquiring “all that’s needed,” according to the complaint.

El Bahnasawy traveled to New Jersey on May 21 in preparation for the attack and was arrested. He pleaded guilty to terrorism charges Oct. 13, 2016 and is scheduled to be sentenced Dec. 12, 2017.

Haroon was arrested on September 2016 in Pakistan, while Salic was busted in April 2017 in the Philippines. Both are awaiting extradition to the US, the feds said.