NEW YORK (AP) — A New York City man plotted to use guns, grenades and suicide vests to bring bloodshed to Times Square, federal prosecutors said Friday.

Ashiqul Alam, 22, of Queens, spoke about his plans with an undercover agent for months, according to court documents. He arranged to buy guns from the agent and went with him on a reconnaissance trip to the bustling Manhattan tourist district in January, the documents said.

Alam "repeatedly expressed interest in purchasing firearms and explosives for a terrorist attack in the New York City area" during conversations with the undercover agent dating to last August, the court documents said.

Alam used his cellphone to take video of Times Square and "explained to the undercover that he was looking for potential targets," according to the documents.

Alam was arrested Thursday after he tried to buy a pair of 9mm Glock semiautomatic pistols whose serial numbers had been obliterated. He is being held at a federal detention center in Brooklyn and is awaiting arraignment on weapons-related charges.

It wasn't immediately known if Alam had a lawyer who could comment on his behalf.

Times Square, which is in the heart of the Broadway theater district and is packed with tourists day and night, has been a target of attacks before.

In 2010, Faisal Shahzad, a U.S. citizen who had gotten explosives training in Pakistan, tried but failed to detonate a car bomb there. He was sentenced to life in prison.

In 2017, a Bangladeshi immigrant, Akayed Ullah, detonated a bomb in an underground pedestrian concourse linking the Times Square subway station to the Port Authority Bus Terminal. Only Ullah was seriously hurt, though bystanders were injured by shrapnel.

That same year, a man who told police he was high on drugs and hearing voices drove his car into the square's crowds, killing a teenager and injuring around 20 people.

Police always have a heavy presence in Times Square and its sidewalks and plazas are partially protected with steel posts intended to stop speeding vehicles.