WELLINGTON, NEW ZEALAND -- Shoppers and staff at a New Zealand supermarket were being praised for their bravery Monday after authorities said they managed to stop a frenzied man from hurting others after he stabbed four people in a random attack, severely wounding three of them.

New Zealand Police Superintendent Paul Basham said he'd watched CCTV footage of the attack at a Countdown supermarket in the city of Dunedin and the actions of the bystanders in detaining the man until police arrived was “nothing short of heroic.”

“What I can say is that 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,” Basham said.

Two of those wounded were supermarket staff members.

On Tuesday, authorities said three of the injured had improved to a serious but stable condition, while the fourth person was in a moderate condition.

Police said they'd charged a 42-year-old man with four counts of attempted murder. The man, who authorities didn't immediately name, was due to make his first court appearance later Tuesday.

The suspect was also injured in the attack and was initially treated for his wounds under police guard before being transferred to a jail.

People in the store at the time told local media that it was a chaotic scene as some people began screaming and running toward the exits while others rushed to help.

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

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

Ardern said five people had been taken to Dunedin Hospital with stab wounds or related injuries.

Health authorities said three of the wounded had been admitted to the intensive care unit at Dunedin Hospital.

“We are shocked and devastated by the events in our Dunedin Central Store this afternoon,” Countdown said in a statement. “Our priority right now is our injured team members and caring for our wider team in the wake of this extremely traumatic event. We are deeply upset that customers who tried to help our team members were also injured.”

Dunedin is home to about 130,000 people, including a large number of students who attend the University of Otago.