MONSEY, N.Y. — Inside the rabbi’s home on the seventh night of Hanukkah, the candlelight ceremony was winding down and the large crowd was filtering into the neighboring synagogue when a man with a covered face barged through the front door.

He unsheathed what witnesses described as a sword nearly the size of a broomstick and started slashing at random, moving through the entryway, then into the dining room and eventually toward the kitchen, where dozens of people — from children to senior citizens — were trying to flee through a back door.

The attack, which officials said began after 10 p.m. Saturday in the New York City suburb of Monsey, would last less than two minutes, leave five people wounded and further unsettle the region’s fearful Hasidic community after a spate of recent attacks on Jewish people.

It would also prompt calls for action to prevent more violence, as New York Gov. Andrew M. Cuomo (D) called for a law punishing mass attacks motivated by hatred of an identity group as domestic terrorism.

Within hours, authorities tracked down and arrested Grafton E. Thomas, a 37-year-old resident of neighboring Orange County, based on the license plate number of a silver Nissan that witnesses had seen fleeing the scene.

Thomas pleaded not guilty to five counts of attempted murder and one count of burglary during a court appearance Sunday, according to the Associated Press. His bail was set at $5 million.

Thomas’s attorney, Kristine Ciganek of the Rockland County public defender’s office, declined to comment.

Local news outlets reported that Ciganek said in court that her client had no criminal record. But according to a security official briefed on the case, Thomas has been arrested at least seven times since 2001, on offenses that include assault, resisting arrest, killing or injuring a police animal, driving while under the influence, possessing controlled substances and menacing a police or peace officer. He appears to have received a jail sentence only for a 2013 arrest for possession of a controlled substance.

Officials have yet to announce a motive in the stabbing in Monsey, about 30 miles north of Manhattan, but state leaders were quick to denounce the attack as an act of anti-Semitism. Weeks earlier, four people were fatally shot in what officials called a targeted attack on a Jersey City kosher grocery store motivated by hatred of Jews and law enforcement.

Saturday’s stabbing shook a county where a third of the population is Jewish and where officials said anti-Semitism has risen in recent years as increasing numbers of Orthodox Jews make their homes there. Police said last month that they would increase patrols in Monsey in response to Jewish residents’ fears, as concerns prompt similar vows of heightened security across the region.

“People in the Orthodox community are connecting dots and are genuinely frightened of the escalation,” said Rockland County legislator Aron Wieder.

As news of the latest assault spread, advocacy groups and local leaders called for concrete steps to address anti-Jewish attacks. Former New York Assemblymember Dov Hikind said the state’s Jewish residents are “sick and tired” of tweets condemning anti-Semitism and want action.

“When will enough be enough?” the Anti-Defamation League echoed in a statement, saying a week of anti-Semitic incidents in the area make it clear that “the Jewish community needs greater protection.”

Cuomo said the state police’s hate crime task force will investigate and called the Monsey stabbing “domestic terrorism” — New York’s 13th anti-Semitic incident in three weeks, he said.

“This is an intolerant time in this country,” Cuomo said Sunday. “We see anger, we see hatred exploding. It is an American cancer in the body politic.”

The president and leaders in Congress were also united in condemning anti-Semitism after the attack, though some Democrats said President Trump should take a more forceful public stance and blamed him for stoking bigotry.

On Sunday afternoon, Trump tweeted, “The anti-Semitic attack in Monsey, New York, on the 7th night of Hanukkah last night is horrific. We must all come together to fight, confront, and eradicate the evil scourge of anti-Semitism."

Community members said that three of the five victims had been treated and released by doctors. Two others remained hospitalized, and at least one was in critical condition with a head wound, Cuomo said at a news conference.

The violence shattered a night of celebration for a tightknit community, witnesses said. The security official briefed on the case said witnesses told law enforcement the attacker entered the rabbi’s house and closed the door behind him before saying, “Nobody going anywhere.”

He started to stab and slice at people seemingly at random, the official said, leaving victims with grave injuries requiring surgery: ruptured hand tendons, a partially amputated limb, wounds to the head, neck, back and arm.

Yisroel Kraus, a 26-year-old teacher who was celebrating Hanukkah at the rabbi’s home with his family, said the assailant swung what looked like a long sword at “everyone he could.” It was lucky, he said, that people had already started to filter out for the night.

“If he had come 10 minutes earlier, the place would have been packed,” he said. “No way to move. No way to run. It was a miracle. It was a Hanukkah miracle.”

Guests tried to fight the attacker off, he recounted: Unable to run, one elderly man threw a chair at the assailant and beat him with a cane.

But the hero of the evening, Kraus said, was his brother-in-law, Joseph Gluck.

Gluck had watched as the attacker unsheathed a “big sword” and began swinging it at those inside, he told MSNBC. Gluck would eventually hit the attacker in the head with a small coffee table from the entryway, he recounted. Both men moved outside.

That’s when Gluck realized that the man was headed toward the synagogue, where congregants locked the doors after hearing the commotion at the rabbi’s house. Gluck screamed warnings, then watched as the man tried a second door.

As the attacker fled to a car and sped away, authorities and witnesses said, Gluck was able to catch the license plate number. That was the critical information that allowed authorities to catch the suspect in Harlem by around midnight, police said — covered in blood and smelling of bleach, prosecutors said, according to the Associated Press.

Kraus ran out the back door of the rabbi’s house and jumped over a gate, he said, ending up at a home a few blocks away where he saw a menorah and knew he’d be welcomed.

An hour later, he gathered with others at the synagogue, where the rabbi spoke of resilience.

“We went on with our daily lives,” Kraus said. “We danced and thanked God that no one got killed.”

Three state troopers were stationed Sunday on a sidewalk across from the rabbi’s house where the attack occurred. Hasidic men and boys gathered around the home and the synagogue next door after the morning ceremony.

Dani Dayan, consul general of Israel to New York, arrived at the house in a black Ford Explorer and met with the rabbi.

“We are in a completely different mode now,” he told reporters gathered on the lawn when he came outside. “In this Hanukkah, we suffered more anti-Semitic incidents than the candles we lit. Impossible to bear.”

Wieder, the county legislator, said anti-Semitism began to rise in the area about a decade ago and has increased noticeably in the past five years. Parents express concern that their children’s schools might be targeted, he said. Synagogue members question the wisdom of open-door policies that have allowed anyone to walk in to pray.

As more Orthodox Jews have moved into the community, Wieder said other residents taunted them anonymously online, then etched Swastikas onto the dirty window of a van and a “for sale” sign in front of a home. An ad for the county’s Republican Party said Wieder was “plotting a takeover” that threatens “our way of life.”

Then, last month, a 30-year-old rabbi said two people came up behind him on a secluded street in Monsey and beat him for several minutes. Police Chief Brad Weidel has said there is no evidence that the man was targeted for his religion, but concerns flared up in the Orthodox community.

On Sunday there was mourning, singing and dancing at a procession of more than 100 Hasidic Jews that ended at the crime scene. The march, led by five law enforcement vehicles, was a previously scheduled celebration to introduce a new Torah at another nearby synagogue.

Rabbi Yossi Fried, 34, shepherded a group of schoolchildren holding oil torches as a light rain fell.

His message for the day: “It has been tough, but in the Jewish religion, we are always taught that there is light, even among the darkness, especially with the children.”

“That is the message we give, no matter what,” he said.

Knowles, Iati and Mettler reported from Washington. Souad Mekhennet in Quiberon, France; Shayna Jacobs in New York; Emily Wax-Thibodeaux in Austin; and Alice Crites in Washington contributed to this report.