A Canadian man was sentenced to 40 years in prison Wednesday for plotting to carry out attacks on the New York City subway system, Times Square and concert venues in the summer of 2016.

Abdulrahman El Bahnasawy, of Mississauga, Ontario, was arrested in May 2016 and pleaded guilty that October to seven terror-related charges, including conspiracy to use weapons of mass destruction, conspiracy to commit acts of terrorism across national borders, and conspiracy to bomb a public transportation system.

"In the name of ISIS, Abdulrahman El Bahnasawy planned an elaborate attack to wreak havoc and destruction on New York City," U.S. Attorney Geoffrey Berman said in a statement. "El Bahnasawy aspired, in his words, to ‘create the next 9/11.’ Thanks to our law enforcement partners in New York, nationally, and internationally, this potentially devastating plot was thwarted."

Prosecutors said that El Bahnasawy conspired with Talha Haroon, a 20-year-old U.S. citizen living in Pakistan; and Russell Salic, a 38-year-old Filipino national who wired money to finance the planned operation. Haroon was arrested in Pakistan in September 2016, while Salic was arrested in the Philippines in April 2017. Both men are awaiting extradition to the U.S.

According to court documents, El Bahnasawy bought bomb-making materials and secured a cabin outside of New York City to use as a safe house, while Haroon consulted an "explosives expert" in Pakistan and made plans to travel to the U.S. to carry out the attacks. The pair discussed their plans with an undercover FBI agent posing as an ISIS sympathizer. At one point in May 2016, El Bahnasawy sent the agent a New York City subway map with markings indicating which train lines they would attack.

Days later, on May 12, El Bahnasawy messaged the undercover agent: "[W]e seriously need a car bomb at times square. Look at these crowds of people!" He also expressed a desire to "shoot up concerts cuz they kill a lot of people ... That's how the Paris guys did it," a reference to the November 2015 terror attacks in the French capital.

PROFESSOR HIRED MERCENARIES TO RESCUE STUDENT FROM ISIS IN IRAQ

Investigators said the attacks would have been timed to coincide with the Muslim holy month of Ramadan, which ran from June 6 to July 5 in 2016.

In a March letter submitted to U.S. District Judge Richard Berman and obtained by Canadian media outlets, El Bahnasawy described years of substance abuse and mental health issues and asked for a second chance.

"I want to experience life away from drugs and away from war and violence," he wrote. "I want a stable life and I want to stop having extreme turns that keep getting me in trouble, like my turn towards drugs or my turn towards jihad."

SYRIAN KURDS SHOCKED, SCARED BY NEWS OF US TROOP WITHDRAWAL

In response, U.S. Attorney Berman said El Bahnasawy had been using opioids and marijuana multiple times while incarcerated and had scrawled graffiti on his cell wall "expressing his support for ISIS and terrorist attacks, and warning that more attacks were to come." One photo showed a scrawled list of high-profile terror attacks, including 9/11 and the Boston Marathon bombing, encircled by what appears to be a heart and the words, "and more coming."

Fox News' Tamara Gitt contributed to this report.