New York City Police Department (NYPD) vehicles patrol in Time Square after a man was arrested in an alleged plot to buy grenades for an attack on Times Square in New York, U.S., June 7, 2019.

A 22-year-old New York City man, Ashiqul Alam, was charged Friday after buy two Glock 9mm pistols with their serial numbers removed, and talking about using a suicide explosive vest in Times Square, according to a federal criminal complaint.

The complaint was released shortly before Alam, who is a citizen of Bangladesh, appeared at a hearing in U.S. District Court in Brooklyn, where Judge Cheryl Pollak ordered him permanently denied. Pollak said that Alam is a danger to the community and a flight risk.

At that hearing, a prosecutor said the evidence against Alam is overwhelming, and also said that he had tried to buy a silencer for the guns that he bought, and had gotten laser eye surgery to be able to fire a gun more accurately.

Alam is charged with possessing firearms whose identification numbers have been removed.

According to authorities, Alam purchased the pistols Thursday from undercover law enforcement officers.

The complaint says that Alam, who is a lawful permanent resident of the U.S., living in Queens, has been eyed by authorities since last August, when an undercover law enforcement officer first met with him.

"During those meetings, Alam repeatedly spoke approvingly about various terrorist attacks, including the September 11th terrorist attacks," the complaint said.

"In addition, the defendant made a number of statements of admiration for various terrorist organizations, including the Islamic State of Iraq and al-Sham," known as ISIS, the complaint said.

Alam also allegedly praised the late leader of the al-Qaeda terror group, Osama bin Laden, who was responsible for the 9/11 attacks.

Alam, according to the complaint, during conversations with an undercover officery had talked about wanting to acquire or use a suicide bomb vest and about using hand grenades or other kinds of explosives during an attack on Times Square "during a large event."

He also allegedly talked about using a suicide vest "in Washington, D.C. to kill a senior government official," the complaint said.

In December, the complaint said, Alam "lamented" to the undercover officer about "not having access to to the types of resources he deemed necessary to carry out the 'plan.' "

When Alam was asked what he needed, according to the charging document, "Alam stated they needed to obtain bomb-making materials, including means to detonate the suicide vest."

In January, the two men visited Times Square to conduct "reconnassaince," the complaint said. While there, "Alam used his cellular telephone to make a video recording of the area," according to the complaint.

"Alam explained to [the undercover officer] that he was looking for potential targets."

When the undercover officer suggested the area around Father Duffy Square, which is located in Times Square, "Alam stated, 'That is the place we hit,' " the complaint said.

According to the same document, Alam and the officer visited a shooting range in Pennsylvania in January, and during that drive Alam allegedl said, "I want to die fighting man."

In 2010, an immigrant from Pakistan, Faisal Shahzad, tried and failed to detonate a car bomb in Times Square.

Shahzad pleaded guilty and was sentenced to life in prison.

Last November, a 20-year-old Canadian man, Abdulrahman El Bahnasawy, was sentenced to 40 years in prison for planning to carry out an attack on a Times Square subway.