US federal authorities charged the 29-year-old Uzbek immigrant they say drove a rented truck into people walking and cycling on a New York City bike path - killing eight - with providing support to a terrorist organisation.
They allege that he was inspired by Isis (Islamic State) to inflict mayhem and chose Halloween because he figured there would be more people on the street.
In court papers, federal authorities said that Sayfullo Saipov told the FBI that he began planning his attack a year ago, though he settled on using a truck as a weapon only two months ago.
Saipov said he was proud of what he had done - even requesting to display the Isis flag in his hospital room - and that he was inspired particularly after he watched a video of Isis leader Abu Bakr al-Baghdadi, court papers say. In that video, Baghdadi questioned what Muslims in the United States were doing to respond to the killing of other members of their faith in Iraq, Saipov told the FBI.
In addition to the terrorism charge, Saipov faces one count of violence and destruction of a motor vehicle - a charge that, because prosecutors allege someone died as a result, could carry with it the death sentence.
More than a dozen people were also wounded yesterday.
Police and FBI officials decried the incident as the worst terrorist attack in New York since September 11, 2001, and they immediately launched an international investigation to uncover how and why it happened. They urged New Yorkers to carry on as normal, even as they said they would beef up security at this weekend's New York City Marathon and explore other steps to prevent a similar incident.
"What happened yesterday was not okay," New York City Police Commissioner James O'Neill said. "It will never be something that any of us just accept as inevitable."
Saipov, who drove for Uber and once had his own trucking company, apparently was radicalised after he came to the United States, and a note written in Arabic that he left at the scene extolled Isis, authorities said.
Translated to English, the note said, in part: "Islamic Supplication. It will endure," court papers say.
"The gist of the note was that the Islamic State would endure forever," said John Miller, the deputy commissioner of intelligence and counterterrorism at the New York City Police Department.
David Patton, Saipov's lawyer, said: "In a case like this involving so much tragedy, it's more important than ever to let the judicial process play out. How we as a society treat Mr Saipov will say more about us than it will about him."
It was not immediately clear whether investigators had found any evidence that others had knowledge of, or assisted with, the plot. The FBI said briefly that agents were looking for another man, identified as 32-year-old Mukhammadzoir Kadirov, or Muhammad Kadirov, in connection with the investigation. But they gave no indication why they were doing so or if he was suspected of having a role, and just minutes later, they said they were no longer seeking him.
"We believed he had information related to yesterday, but we are not looking for that individual any longer," said FBI Assistant Director in Charge William Sweeney, adding, "We have found him, and I'll leave it at that."
A person who was in touch with both Saipov's and Kadirov's families said that Kadirov is in New Jersey, has retained a lawyer and is cooperating with law enforcement officials, but that he was not under arrest.
The person said Kadirov is Saipov's cousin. The person, who spoke to Kadirov over the phone, said Kadirov seemed "utterly shocked and horrified" by what Saipov had done.
Investigators found on Saipov's phones 90 videos and 3800 images, many of which seemed to be Isis propaganda, videos of the group's fighters killing prisoners or bomb-making instructions. He told agents that he wanted to kill as many people as he could and considered putting Isis flags at the front and back of his truck - but ultimately decided it would draw too much attention, court papers say.
National security officials have warned that as Isis is being routed in Syria and Iraq, the group's supporters might try to carry out crude attacks in the places where they live. The group has urged its supporters to use vehicles as weapons, and the tactic has been employed in France, Britain, Germany, Sweden, Spain and Canada.
The group, though, did not immediately claim responsibility for the incident in New York, according to the Site Intelligence Group, which monitors extremist activity.
Officials on both sides of the political aisle agreed that Saipov's rampage was an act of terrorism, but there was almost immediate disagreement on how to respond.
President Trump decried the way Saipov entered the United States - via a State Department programme that grants visas to people from countries with historically low rates of immigration to the United States - and said he would ask Congress to end it. On Twitter, Trump asserted that he would increase already "extreme" vetting of those wanting to come to the country, and he took a swipe at Senate Minority Leader Charles Schumer, (D).
I have just ordered Homeland Security to step up our already Extreme Vetting Program. Being politically correct is fine, but not for this!
New York Governor Andrew Cuomo, (D), fired back that Trump's tweet was "not helpful" and said he was "bothered by an attempt by anyone to politicise this situation".
The President also said he was considering sending Saipov to the US military prison at Guantanamo Bay, Cuba, and White House press secretary Sarah Huckabee Sanders said later that "I believe we would consider this person to be an enemy combatant".
Sanders, though, did not seem to affix any legal meaning to the term, and of sending Saipov to Guantanamo Bay, she said Trump was trying to indicate that he "would support that, but he wasn't necessarily advocating for it".
Even the suggestion of labelling Saipov an enemy combatant or putting him in Guantanamo Bay - which probably would spark years of legal wrangling - drew immediate condemnation from civil liberties groups. The court system at the military prison is still struggling to bring to trial those accused of playing roles in the 9/11 attacks.
"Military detention would be unconstitutional, contrary to congressional statutes and unnecessary," said Hina Shamsi, director of the ACLU National Security Project.
Saipov is alleged to have ultimately crashed into a school bus and emerged from his truck armed with a paintball gun and pellet gun. A passer-by flagged down police officers responding to an unrelated call at a school in the area, and one of them shot and wounded Saipov, police said.
Among those Saipov is accused of killing were a group of childhood friends from Argentina, now in their late 40s, who had been planning a trip to New York for years; a young mother; and two men in their 20s and 30s from New York and New Jersey.
Police said Saipov had never been the "subject" of an FBI or New York police investigation, though they stopped short of saying he was unknown to law enforcement. Miller said "he will have some connectivity to individuals who were the subjects of investigation, though he himself was not." Law enforcement officials said the FBI has been investigating a friend of Saipov's, but that probe had not previously found derogatory information against Saipov.
Saipov arrived in the United States in March 2010 and lived in Ohio, Florida and New Jersey, according to authorities. He started a trucking company, was married, had children and at one point, worked for Uber, where he passed a background check. His wife has told the FBI that she did not know he was planning violence, a person familiar with the case said.
Those who knew Saipov said they were surprised by what had happened - though some acknowledged that he had antagonistic tendencies.
Mirrakhmat Muminov, 38, a truck driver in a suburb of Akron, Ohio, said that Saipov lived in his community and worked part-time for his trucking company for a few months. But he had to fire him because he was often late for deliveries and was aggressive with customers.
"He was always aggressive and nervous," Muminov said in an interview. "We warned him in our community: 'Don't be nervous. You have to stay calm.' "