Parliament has passed legislation to increase the length of time imprisoned mothers can keep their babies with them.
The Green Party amendment to the Corrections Act was passed unanimously under urgency on Thursday afternoon.
It will mean mothers with babies can keep them in prison until they turn 2 years old. At present, babies can only stay with their mothers in prison until they are six months.
Though the legislation was in Green MP Sue Bradford's name, the Government picked it up to ensure it could pass into law before the election later this year.
Ms Bradford says she has accepted financial constraints, which mean the law will only be applied where facilities are available.
Eight mother and baby units will be established in women's prisons at Auckland and Christchurch at a cost of $2 million.