Three people are dead, including the gunman, and at least six are injured after an Auckland CBD shooting described by New Zealand Prime Minister Chris Hipkins as a "very grim morning".
A police officer, who was critically injured but has since stabilised, is among the injured from the attack at a building and construction site.
Aucklanders on their city commutes were shocked early on Thursday, hearing gunfire outside a building on Queen St, the city's thoroughfare, about 7.20am.
Dozens of police vehicles, a helicopter and several ambulances scrambled to attend once the threat became clear.
Local media reported the gunman was a 24-year-old man who worked at the building, and had arrived there with a pump-action shotgun.
He was later identified as Matu Tangi Matua Reid, who was serving a community-based sentence of home detention for family violence offences.
Colleagues thought he was conducting a prank until he opened fire.
Police said Reid "moved through the building site and continued to discharge his firearm".
"Upon reaching the upper levels of the building, the male has contained himself within the elevator shaft," a police statement read.
"Further shots were fired from the male and he was located deceased a short time later."
Local television outlets broadcast footage of workers on the roof of the building hiding behind packs of pre-mix cement.
Police Commissioner Andy Coster said they had "contained the situation and were not seeking anybody else".
"Thankfully, many people were able to escape the building but I know that for those who hid or remained trapped, this was a terrifying experience," he said.
The shooting is being treated as an isolated incident, not a national security threat, with no change to the country's terror settings.
Mr Hipkins said he had "deep sorrow" for the two victims, who were civilians killed inside the building.
"I want to thank the brave men and women of the New Zealand police who ran into the gunfire, straight into harm's way in order to save the lives of others," he said.
"These kind of situations move fast and the actions of those who risked their lives are nothing short of heroic."
Mr Coster said Reid had indications of a "mental health history", and they believed his motivation was linked to his employment.
In New Zealand, people serving home detention can gain exemptions to visit work sites.
The commissioner said it was unclear whether the attack could have been foreseen by police, or prevented.
"Any time (sentencing) decisions are being taken there is a weighing of risk," Mr Coster said.
"There was nothing to suggest that he has presented a higher level risk than was indicated."
St John Ambulance confirmed six injuries - three serious and three moderate - in addition to the deaths.
All were taken to Auckland Hospital, where the injured police officer will undergo surgery on Thursday afternoon.
Mr Coster said there may have been others injured who self-presented at hospital.
Australian Prime Minister Anthony Albanese, who is to visit Wellington next week, offered condolences.
"I've been in contact with with Chris this morning ... it is very sad indeed to see another dreadful shooting with fatalities," he said.
The incident occurred on the first day of the Women's World Cup, with NZ set to play Norway in the tournament's opening match at Eden Park.
Mr Hipkins said there would be no change to the tournament schedule, following conversations with FIFA officials.
Norway are staying at a hotel in close proximity to the shooting site.
Mayor Wayne Brown told TVNZ the attack was "dreadful".
"It couldn't have come come at a worse time given the world has its eyes on us now with the FIFA soccer thing," he said.