Federal investigators have foiled an ISIS-inspired mass shooting and bomb plot targeting Times Square, concert venues, and the subway system in New York City.

Prosecutors on Thursday unsealed charges against Canadian citizen Abdulrahman El Bahnasawy, 19, Philippine citizen Russell Salic, 37, and Talha Haroon, a 19-year-old US citizen residing in Pakistan.

All three were arrested months ago, but the charges had been sealed as investigators with the FBI and NYPD Counterterrorism Unit searched for possible co-conspirators.

El Bahnasawy is in US custody and has pleaded guilty to federal terror charges, while the other two men await extradition from foreign custody to face charges in the US.

Prosecutors say the three men plotted to bomb and shoot up heavily populated areas of New York City during the Islamic holy month of Ramadhan in 2016.

El Bahnasawy took the lead on the ground, entering the US from Canada to secure a cabin near New York City to use as an operating base and bomb-making facility, according to investigators.

Meanwhile, Haroon met with explosives experts in Pakistan and planned to join El Bahnasawy in the US to carry out the attacks, and Salic sent support funds from the Philippines, according to prosecutors.

‘[W]e seriously need a car bomb at times square… Look at these crowds of people!’ El Bahnasawy messaged the undercover agent along with a picture of the New York City landmark last May, according to prosecutors.

El Bahnasawy also spoke glowingly of a plan to ‘shoot up concerts cuz they kill a lot of people,’ the indictment said.

‘[W]e just walk in with guns in our hands. That’s how the Paris guys did it,’ the message said in apparent reference to the November 2015 attacks on the Bataclan theater, which left 130 dead in Paris.

Meanwhile, Haroon allegedly felt that the New York subway was a ‘perfect’ target, telling the undercover there would be plenty of ‘women and kids’ to target and adding: ‘when we run out of bullets we let the vests go off.’

Harron also mused about an attack on Times Square in Midtown Manhattan, allegedly sending the message: ‘We surround the whole street and trap them and kill as many as possible.’

‘I wanna kill… them in thousands’ he allegedly wrote, ‘we have to make a ocean out of their blood… Leave no one standing.’

‘NY Needs to fall. It’s a must,’ Haroon allegedly texted the undercover federal agent.

In the Phillipines, Salic, aka ‘The Doctor’, allegedly played the money man, sending funds to support the plot against New York City.

Prosecutors said that Salic gloated about the benefits of operating out of the Philippines in a message to the undercover: ‘Terrorists from all over the world usually come here as a breeding ground… hahahaha… But no worry here in Philippines. They dont care bout IS[IS]… loll Only in west.’