The prohibition also applied to farms that raise "any breeding pig" or "calf raised for veal."
The law was set to take effect in 2022.
Democratic Senate President Karen Spilka said in a statement Wednesday that when Massachusetts voters approved the ballot question in 2016, the state had some of the strongest protections for farm animals in the country.
"Since then, national and industry standards have shifted towards even stronger animal welfare and consumer safety protections," she said. "With this law, Massachusetts is taking action to prevent cruelty to farm animals and ensure that our state has continued access to eggs."
Egg industry leaders had said that if state legislators did not make changes to the law, up to 90% of the egg supply in the state would disappear in January.
Some animal advocates had urged Baker, a Republican, not to sign the bill, saying it undercuts what voters approved in 2016.
Under the voter-approved law, hens were to receive "the smallest amount of relief from abject cruelty," said Tracy Reiman, vice president of People for the Ethical Treatment of Animals or PETA
"Now even that pittance is to be snatched away by this deeply cruel industry," Reiman said in a press release before Baker signed the changes into law. "We urge consumers to refuse to buy eggs, for which chickens suffer mightily."
Other animal rights groups say they support the changes approved by lawmakers and signed by Baker.
Click here to see more...