A Pakistani man who federal authorities said had been drawn into plotting on behalf of the Islamic State group pleaded guilty Wednesday to a terrorism charge tied to a planned attack on a Jewish religious center in Brooklyn, prosecutors said.

Muhammad Shahzeb Khan entered the plea in Manhattan federal court before U.S. District Judge Paul G. Gardephe, according to the U.S. government’s presentation of the case and a Justice Department release referenced in court filings and proceedings.

Prosecutors said Khan acknowledged that he answered the group’s call for Muslims to kill Jewish people by plotting to attack the Brooklyn center in October 2024. They also said the plan contemplated using automatic weapons to carry out a mass-casualty shooting.

In describing the motivation and timing, Assistant Attorney General for National Security John A. Eisenberg said the plot was intended to coincide with the anniversary of the Oct. 7, 2023, Hamas attacks, with the “explicit goal of killing as many Jews as possible,” the release said. The government also said Khan had boasted he would carry out the largest attack on U.S. soil since the Sept. 11 attacks.

Khan, 21, told the judge that he intended to cross the border from Canada into the United States in September 2024 with “the intention of killing Jewish people in Brooklyn,” according to the proceedings as described by prosecutors. He also said he was motivated by what he described as retaliation for Israel’s killings of Palestinians in Gaza.

As part of his plea, Khan said he regretted the plan and told the court, “I was not raised this way,” adding that what he planned to do was wrong. The government said he called the plot to kill Jewish people a “terrible, extremely dangerous and morally reprehensible idea.”

The case had begun with Khan’s arrest in Canada, federal authorities said. They said he was taken into custody in or near Ormstown, Canada, on Sept. 4, 2024—about 12 miles from the U.S. border—and that he had been in Canada after being granted a student visa in May 2023 and arriving in Toronto in June.

Authorities said Khan came to investigators’ attention after he began posting about his support for the Islamic State group in November 2023. They said he later began planning terrorist attacks in the United States and communicated with two undercover law enforcement officers, including discussing an intended target described by prosecutors as a prominent Jewish religious center in Brooklyn.

According to the release cited by the government, Khan told the undercover officers that “New york is perfect to target jews” because it has the “largest Jewish population in america,” and he wrote that they would “go to nyc to slaughter them.” Prosecutors said his online messages described the Brooklyn site as the “ultra orthodox hasidic jews world headquarters.”

Judge Gardephe set sentencing for Aug. 12. Prosecutors said Khan could face up to life in prison at that hearing.