MONTREAL — Police in Quebec City said Sunday that they had arrested a man dressed in medieval garb and brandishing a sword after a series of stabbings on Halloween night left at least two people dead and five others wounded.

The attacks occurred late Saturday in a historic district of Quebec City near the building that houses the provincial parliament.

“People are shocked. It has all the ingredients of a horror film, a man disguised who goes out on Halloween and kills people,” said Hadi Hassin, a local journalist who lives in the area. “I go out every night in the district and will be spooked for a while.”

Robert Pigeon, chief of police in Quebec City, said that the suspect was 24 and that the attack appeared to have been premeditated and motivated by personal reasons. He said that the suspect came from the suburbs north of Montreal, was not associated with any terrorist organization and did not have a previous criminal record, but the police chief added that medical records from five years ago showed that the man had previously threatened an act of violence.

The police chief said that the attacker had used a Japanese-style sword and had lunged at his victims, appearing to choose them randomly. He said the attacker had acted “with the intention of doing the most damage possible” and noted that officers were investigating 25 crime scenes. The suspect was expected to appear in court via video conference Sunday, he added.

Pigeon said that some of the five wounded people, who were all residents of Quebec City, had suffered severe lacerations but that their injuries did not appear to be life-threatening.

Maitreyi Pal-Singh, a medical student from New York who lives in the district where the attack took place, said she was walking home about 10:45 p.m. Saturday when she saw police cars circulating. She said that she had stayed up all night with a neighbor and had locked herself in her apartment for the most part, venturing out periodically to look through a window to try and determine what was happening.

“Police shut down my street. It was terrifying — it was Halloween, and there were some kids dressed as Batman or Spider-Man trick-or-treating before everything was closed,” she said. “You don’t expect something like this to happen in Canada and especially Quebec City.”