A New York man who talked about staging a terrorist attack in Times Square has been arrested on weapons charges, according to court papers. (Richard Drew/AP)

Federal authorities have arrested a New York man who they allege praised terrorist organizations and plotted an attack in Times Square, according to charging papers filed Friday.

Ashiqul Alam — a 22-year-old Bangladeshi citizen and lawful permanent U.S. resident who lived in Queens — did not know he was scheming with undercover government agents, and he was taken into custody Thursday after he and one of the agents bought weapons to use in a possible attack, according to the charging papers. He is charged in federal court in Brooklyn with a weapons offense, because the guns had their serial numbers removed.

As far back as August 2018, Alam had been planning with an undercover law enforcement agent — professing his admiration for the Islamic State and the deceased al-Qaeda leader Osama bin Laden and musing about carrying out attacks of his own, according to the charging papers. He talked of using a suicide vest in New York City’s Times Square or in Washington, D.C., or perhaps obtaining an AR-15 to kill law enforcement officers, according to the papers.

Alam and the undercover agent conducted reconnaissance in Times Square, and in early 2019, they traveled to a shooting range in Pennsylvania, according to the papers.

“I want to die fighting, man,” Alam told the undercover agent, according to the papers.

Alam’s defense attorney did not return an email seeking comment.

The charging papers seem to suggest Alam’s ambitions exceeded his abilities and means, and he worried about being perceived as hapless. In April 2019, for example, when the undercover agent asked Alam about an upcoming eye surgery he had scheduled, Alam responded while laughing, “Let’s say we are in an attack, right, say that my glasses fall off. What if I accidentally shoot you?” . . . Imagine what the news channel would call me. The ‘Looney Tunes Terrorist’ or the ‘Blind Terrorist,’” according to the papers.

He told the undercover agent at one point they should buy just a single Ak-47, because purchasing two would be too expensive, the papers allege. He also talked about buying grenades, if he could not find other explosives.

In recent months, Alam and the undercover agent discussed purchasing firearms, and the undercover agent connected Alam with other people working for the government, according to the charging papers. Alam decided he wanted to buy two Glock pistols, and on Thursday, he and the undercover agent did so — for $400 a piece, from another person working for the government.

Alam, according to the charging papers, also told the undercover agent he wanted to buy an enhanced driver’s license so he could “walk on to a military base” and “blow it up,” the charging papers allege.