NEW YORK — A man who allegedly threatened to stage a grenade attack in Times Square was ordered held without bail Friday after he was arrested on weapons-related charges in a sting by undercover investigators.

Ashiqul Alam, 22, a Bangladeshi citizen who is a lawful permanent U.S. resident, was busted after allegedly discussing and boasting about his attack plans for months with an undercover federal investigator.

Alam's alleged threatening statements were characterized as “aspirational,” and the planning never reached a stage that could endanger the public, law enforcement sources told the Associated Press.

However, William Sweeney, the assistant director in charge of the FBI's New York field office, said in a statement "there is more to this case than just talk and the desire to carry out a terrorist attack."

"Individuals who believe in the distorted and deadly propaganda of terrorist organizations and work toward acting on those deadly impulses are incredibly dangerous and unpredictable," said Sweeney.

Authorities said Alam, who lives in the New York City borough of Queens, was arrested on Thursday by members of the Joint Terrorism Task Force, a unit that includes members of the FBI and the New York City Police Department.

The suspect made an initial federal court appearance in Brooklyn before U.S. Magistrate Judge Cheryl L. Pollak. She agreed with prosecutors that Alam is a safety and flight risk who should be detained without bail, and rejected a bail package presented by Federal Defender James Darrow.

Darrow did not immediately respond to a phone message seeking comment. Pollak scheduled a preliminary hearing for June 21.

A newly unsealed federal court complaint filed against Alam alleged that for months he discussed buying grenades, other explosive materials and weapons in preparation for an attack in New York City — all without realizing he was speaking to an undercover criminal investigator.

Accompanied by the investigator, Alam twice conducted reconnaissance in Times Square, filming the nationally famous urban landmark with a cell phone, the court complaint said.

"Alam stated that if they completed an attack successfully, then they would become 'legends,'" FBI Special Agent Sean Dillon stated in the court filing.

During another meeting, on March 21, the undercover agent asked Alam what would make him happy. "Seeing the flag of Islam on the Twin Towers or the Empire State Building," Alam replied, according to the court complaint.

During discussions with the undercover agent, Alam allegedly agreed to meet individuals he believed were willing to sell weapons that had their identifying serial numbers obliterated.

"Oh, that's good, man," Alam said, after learning that the weapons would be difficult to trace, the court complaint alleged.

He also discussed buying hand grenades, theorizing that one of the devices could "take out at least eight people" if it exploded indoors in a mall or large gathering, according to the court filing.

On Thursday, Alam allegedly joined the initial undercover agent in a Brooklyn apartment where the two met with other undercover investigators who posed as weapons dealers.

The suspect provided half of the total $800 cost for two Glock 19 pistols, paying in $100 bills, the court complaint charged. Investigators arrested Alam immediately after the purchase.