Home Affairs Minister Clare O'Neil moved to put in place a preventative detention regime usually reserved for terrorists and spies after the High Court ruled indefinite immigration detention was illegal.
The court's decision led to the government being forced to release some 150 detainees.
Three detainees, including registered sex offenders, have been arrested and charged. Two remain behind bars after bail was refused.
The arrests have been used by the coalition as fuel for the political fire it's heaping towards the government and ministers for how the situation has been handled.
The government should have had legislation in place before the High Court's decision so it was ready to go as soon as the ruling was handed down to prevent the release of any detainees, Nationals senator Bridget McKenzie said.
Bridget McKenzie criticised the government's handling of immigration detention after the ruling. (Mick Tsikas/AAP PHOTOS)
But the government was hamstrung by the High Court's decision which mandated the release of detainees in the same situation as the original complainant, NZYQ, it says.
Legislation could not have been put in place to detain the whole cohort due to the ruling, Attorney-General Mark Dreyfus said as he offered to show the opposition the legal advice received by the solicitor-general.
"Following the High Court decision and reasons in the NZYQ matter, it is not legally possible to legislate to require the detention of all of the NZYQ-affected individuals on community safety grounds," he wrote in a letter tabled in the Senate.
Any delay in releasing affected detainees could open the government and individual officers up to legal claims of false imprisonment, he added.
The opposition is pushing for stronger requirements from the ministers who ticked off on the release of detainees, calling for a statement of reasons as to why they needed to be set free.
Mark Dreyfus offered to show the opposition the legal advice received by the solicitor-general. (Lukas Coch/AAP PHOTOS)
"Tell us how the High Court decision actually applies to each," shadow attorney-general Michaelia Cash said.
The preventative detention laws will allow the released detainees to be put back behind bars if a court decides there's "a high degree of probability that the person poses an unacceptable risk of committing a serious violent or sexual offence".
It would also be a criminal offence for people who have been convicted of serious or violent sexual offences to go near a school or contact their victim or their victim's family.
The maximum length of the order is three years and the minister will need to reapply to the court for a review every year.
Enhanced supervision could also be put in place if a lower threshold relating to community safety is met.
The order would again last for a maximum of three years and need to be reviewed by the court every 12 months.
Breaching this order carries a mandatory minimum sentence of one year behind bars and a maximum of five.
The laws are set to be ticked off by the lower house on Thursday.
1800 RESPECT (1800 737 732)
National Sexual Abuse and Redress Support Service 1800 211 028
Lifeline 13 11 14
Kids Helpline 1800 55 1800 (for people aged 5 to 25)