New battery hen cages will be banned and existing cages phased out over the next decade under a new welfare code in effect from tomorrow.
Primary Industries Minister David Carter said scientific evidence and strong public opinion made it clear change was necessary.
The move has already drawn criticism from the industry, which says the actual phase-out period will be a "crippling" four to six years, and the Green Party, which says it does not go far enough by failing to ban colony cages.
More than 80 per cent of New Zealand's eggs are laid in battery cages, which house three to five hens in a minimum area of 550sq cm per bird - smaller than an A4 sheet of paper each - restricting them from expressing a range of normal behaviours.
The new welfare code, developed by the National Animal Welfare Advisory Committee (NAWAC), means egg producers will only be able to keep hens in larger colony cages, barns or free range environments by 2022.
New battery cages will be banned from tomorrow, while existing cages will have to be removed under a staged phase-out over the next decade, with 45 per cent of existing cages to be removed by 2018.
Mr Carter said the code was a major shift for the industry.
"An immediate prohibition of battery cages would have an unacceptable impact on egg prices, industry structure and the stability of egg supply.
"The phased approach balances the welfare of layer hens with the time needed for producers to transition to other systems."
Green Party animal welfare spokeswoman Mojo Mathers said the new code still allowed chickens to suffer in colony cages.
"These colony cages do not meet the fundamental purpose of the Animal Welfare Act. By releasing this code the minister is entrenching the use of loopholes to allow factory farms to continue to keep animals in cruel conditions."
Egg Producers Federation chairman Michael Guthrie said he supported the general thrust of the code, which allowed the industry to leave behind the negative connotations of cages.
But he said the 10 year phase-out period was more likely to be four to six years in practice.
"This will have an enormous, possibly even crippling impact on many in the industry."
Mr Guthrie said farmers using battery cages would be able to salvage little of their current operations and would have to completely rebuild their farms from scratch, many on different sites.
The estimated cost of moving to colony cages was $150 million, while the cost of moving to free-range would exceed $250m.
NAWAC chairman John Hellstrom said the new welfare code was developed after reviewing the existing 2005 code and considering scientific evidence and submissions from the public.
The Animal Welfare (Layer Hens) Code of Welfare 2012 contains minimum standards and best practices for all aspects of layer hen care and handling, including the provision of food and water, shelter and health.
"The new code will ensure that hens live in an environment that meets their welfare needs and lets them carry out a range of normal behaviours, such as perching, pecking and scratching," Dr Hellstrom said.
Larger colony cages were acceptable under the code because they allowed hens to display a range of normal behaviours, he said.
"Colony cages are bigger, typically housing 40-60 birds, and include a secluded nesting area, perches and a scratching area."