Immigration New Zealand mistakenly detained the stepfather of murdered schoolgirl Karla Cardno because it did not have the right paperwork.
The cause of the blunder was revealed in a new report on the department's processes, spurred by the Mark Middleton case, and another where it tried to deport a woman after she reported a serious crime.
The review found staff are not taught how to apply discretion to some sensitive cases, and do not know when to prioritise cases.
Mark Middleton had lived in New Zealand for 56 years, since his family emigrated from Britain.
He was shocked when immigration officers turned up at his work in April to tell him he was being kicked out of the country.
He had been accused of being in the country unlawfully after going to Fiji for a holiday in 1986 - the first time he had gone overseas since moving here with his family.
"They came and got me, took me out on the pavement, wouldn't listen to anything I had to say, and were threatening to deport me in three days, and that was it.
"They took all my stuff off me, and threw me in the jail."
The experience left him feeling betrayed.
"To have someone walk into your life and drag you out of your place of work and say, 'We're going to deport you out of the country...' What's that about?"
Read the full report here:
A public backlash, sparked by the fact the rest of his family had not been accused of overstaying, prompted Associate Immigration Minister Kris Faafoi to reconsider the case and grant him a visa.
But another decision a few months later, when officers detained and tried to deport a woman who had reported a serious crime, led to Immigration New Zealand starting a review of its processes.
It found staff were not taught how to apply discretion.
It also found Mr Middleton should not have been locked up - and, if officers had the right papers, he would not have been.
"Certainly for these two individuals it wasn't an ideal outcome for them at all, and we feel we've put that right," said Immigration NZ head of immigration Greg Patchell.
"As public servants... our job is to conduct ourselves in a way that the public can have confidence in," he said.
"In a couple of these situations that's potentially been dented."
The review did have a positive side - namely, that these mistakes were one-offs.
Mr Patchell said they dealt with thousands of deportation cases a year so the occasional wrong call was inevitable - but still unacceptable.
He said Immigration NZ accepted all the review's recommendations, and were changing their processes accordingly.
"For Mr Middleton, the experience he had - although lawful - I think we admit, and apologise to him, that it could've been handled more tactfully and more appropriately."
But Mr Middleton rubbished Immigration New Zealand's claims of remorse.
He said he had not received an apology, and while he wanted one, he was also seeking compensation for his time in the cells.
"I don't trust the system for nothing," he said.
"I feel stabbed in the back, and I feel betrayed."
Immigration New Zealand's processes had been under intense scrutiny this year, following the now overturned decision to let Czech drug-smuggler Karol Sroubek stay in the country.
Immigration lawyer Alastair McClymont said Sroubek's case, and the two at the centre of this review, showed immigration staff were terrified to make judgement calls.
"They've just become so obsessed about following process, that what happens is any kind of commonsense decision-making has just come out the window.
"Everything is just process, process, process.
"Quite only the often way of actually getting the right decision made is to get out with a megaphone and yell and scream at the top of your voice, so that the New Zealand public can scream, 'Hey! What's going on here?'"
A separate review into how Immigration New Zealand prepares files for ministers was also under way.