SYDNEY — Police praised "heroic" bystanders for disrupting a frenzied knife attack at a New Zealand grocery store on Monday.

A man wielding two knives allegedly stabbed four people, three of them critically, before he was detained by onlookers and held until police arrived at the supermarket in Dunedin, a university town of around 130,000 people on New Zealand’s South Island.

Surveillance footage of the attack showed the actions of the bystanders were “nothing short of heroic,” said New Zealand Police Superintendent Paul Basham.

“Those that intervened, some of whom became injured themselves, I think have acted selflessly and with great courage to prevent this man from hurting anybody else,” he told reporters.

Violent incidents in the island nation of 5 million people are rare. New Zealand tightened gun laws in 2019, less than 24 hours after an Australian man opened fire at two mosques in Christchurch, New Zealand, and killed 51 worshipers with weapons that included an assault rifle.

Prime Minister Jacinda Ardern said the motivation for Monday’s attack had not been established but police didn’t have any evidence to suggest it was domestic terrorism.

“Such an attack is hugely concerning and I do want to acknowledge the early reports of courageous acts by bystanders who have taken action in order to protect those around them,” Ardern told reporters. “Our thoughts are with all those who have been affected by this attack.”

Five people were taken to hospital after Monday’s incident, including the alleged attacker, who was under police guard. Two of the injured were supermarket workers.

The attack began around 2:30 p.m. local time. Witnesses described a chaotic scene as people began screaming and running toward the exits while others rushed to help.

One witness told local media she believed the attacker was on drugs. Another said a man was having a psychotic episode and used two knives to stab people before being disarmed by people in the store, including staff.

Jenny McDowell said she was doing her supermarket shopping when she heard screaming and swearing.

“I looked up and there was a man stabbing a woman — she had blood around her head,” she told a local television network. “Members of the public came to just restrain him — they were doing everything they could, they were throwing stuff at him. … They were heroes, they really were.”

She said she emptied out her bag thinking she could use it as a tourniquet. While she did so, a supermarket worker removed his jersey and began applying pressure to the victim’s wound.

Dunedin City Mayor Aaron Hawkins said the incident was hard to comprehend.

“Everyone should feel safe in their place of work, or doing everyday errands like grocery shopping,” he wrote on Twitter. “The chilling thing about this is that it could have been any of us, or our families, at this busy central city location.”

“On the face of what we currently know, we believe this was a random attack,” said Basham, the police superintendent.

In a statement, Countdown supermarkets said they were “shocked and devastated by the events.”

The man was expected to appear in court Tuesday.