Times Square is one of the most visited destinations in the United States.

A New York man who prosecutors say plotted an attack on Times Square, spoke about killing police officers and praised terrorists appeared in court on firearms charges on Friday and was denied bail.

Ashiqul Alam, 22, from Jackson Heights in the city's Queens borough, was charged with illegally acquiring firearms as part of the attack plan, federal officials said.

US Magistrate Judge Cheryl Pollak ordered Alam detained without bail after a brief court hearing in US District Court in Brooklyn on Friday. His next court appearance is set for June 21 at 11 a.m. (1300 GMT).

Alam's lawyer, James Darrow, had asked for his client to be released on $200,000 bond, under home confinement and with an ankle monitor. He said Alam lived with his parents, who were both in the courtroom and prepared to sign the bond.

Alam was arrested on Thursday after receiving two Glock 19 nine-millimeter semi-automatic pistols with their serial numbers stripped off from undercover law enforcement officers, according to a complaint unsealed on Friday in Brooklyn federal court.

During meetings with an undercover federal agent, Alam expressed support for the Sept. 11, 2001, attacks on New York as well as the terrorist group ISIS, according to the complaint. He also discussed using an explosive suicide vest in an attack.

"As alleged, Ashiqul Alam bought illegal weapons as part of his plan to kill law enforcement officers and civilians in a terrorist attack on Times Square," US Attorney Richard Donoghue, whose office brought the charges, said in a statement.

Alam had proposed an attack either in Times Square or an attack in Washington to kill a US government official, the complaint said.

In April, Alam met the undercover officer at a shooting range in Pennsylvania, according to the complaint. While driving to the range, Alam told the officer that he had scheduled an appointment for laser vision correction, the complaint said.

When the officer asked him why, Alam said he was concerned his glasses would fall off during the attack and he would accidentally shoot the officer, and joked that the media would call him the "Looney Toons Terrorist" or "Blind Terrorist," according to the complaint.

Alam is a rising senior at John Jay College and has two jobs, his lawyer said at the hearing. When asked about Alam, a spokesman for John Jay College said it does not release information about individual students.

Times Square, with its millions of visitors each year, is often called the crossroads of the world, and has been targeted by at least two bombers in recent years, despite the presence of heavily armed police.

On May 1, 2010, police thwarted an attempted car bomb in Times Square, defusing a crude device made out of firecrackers and propane gas tanks.

A Pakistani-born US citizen pleaded guilty to the plot, admitting that he had received bomb-making training from the Pakistani Taliban and that the group, known as Tehrik-e-Taliban Pakistan had funded the plot. He was sentenced to life in prison.

In December 2017, a Bangladeshi man set off a homemade pipe bomb strapped to his body in a crowded underground pedestrian tunnel near Times Square. The man, Akayed Ullah, was convicted of six criminal counts, including use of a weapon of mass destruction and support of a terrorist organization.

Kate Fan, a 28-year-old charity worker visiting from Guangzhou, China, said she had heard about the incident but still felt safe.

"We hear a lot of stories about New York being unsafe, but we feel like people sometimes exaggerate safety issues," she said.