New Zealand had tried for years to deport the knife-wielding militant who wounded seven people at a mall in Auckland last week, the government said after it released more details on the attacker following the lifting of a court suppression order.
Court documents made public on Sunday identified the attacker as Ahamed Aathil Mohamed Samsudeen, 32, an ethnic Tamil Muslim from Sri Lanka. He had arrived in New Zealand 10 years ago on a student visa seeking refugee status, which was granted in 2013.
Police were following Samsudeen and shot him dead about a minute after he launched his attack on Friday after picking up a knife from a supermarket display. He had been convicted and imprisoned for about three years before being released in July.
Samsudeen's family issued a statement to the New Zealand media describing their shock at the "terrible event".
Samsudeen was inspired by the Islamic State militant group and was being monitored constantly but he could not be kept in prison by law any longer, the government has said.
He came to the attention of the police and security services in 2016 after he expressed sympathy on Facebook for militant attacks, violent war-related videos and comments advocating violent extremism.
It was subsequently discovered that his refugee status was fraudulently obtained and the government moved to cancel his visa and issued deportation notices.
But Samsudeen appealed against the deportation, and since he was in prison, his appeal could not proceed until his criminal trial ended in May this year.
The attack has led to questions about a loophole in counter-terrorism laws that allowed Samsudeen to remain free despite authorities being aware of the threat he posed.
The government has promised to tighten the law, in particular to criminalise planning a militant attack.
"We will continue to review our immigration laws alongside the terrorist suppression law and I'm sure if there are ways we can improve it, we will," Deputy Prime Minister Grant Robertson told a news conference.
Prime Minister Jacinda Ardern said in a statement on Saturday that unsuccessful attempts to deport Samsudeen was a "frustrating process" for the government.
Of the seven people wounded in the attack three are in critical condition. One person has been released from hospital.
Samsudeen's family said in the statement they were heartbroken.
"We hope to find out with you all, what happened in Aathil's case and what we all could have done to prevent this," the family said in the statement, released by his brother Aroos.
The family said Samsudeen was suffering from some mental health problems and his condition got worse over the past 10 years as he spent more time in prison and dealing with court cases.
"He wanted to share the sufferings and injustices. He saw himself as someone fighting those injustices," the family said.