The law passed on Thursday night, and led to chaotic scenes in the statehouse as anti-vaccination supporters clashed with lawmakers.
Much of New York’s outbreak has centred around orthodox Jewish communities.
More than 1,000 Americans have been diagnosed with measles in 2019. Health officials say the disease is resurging.
Last month, the US Centers for Disease Control and Prevention (CDC) warned that the US, which effectively eliminated measles in 2000, may lose its “measles elimination status” as infections climb to a 27-year high.
The new law in New York, which was passed by the state’s Democratic Senate and Assembly chambers, bans parents from claiming religious exemptions which used to allow their children to forgo vaccinations that are normally required for school.
“I’m not aware of anything in the Torah, the Bible, the Koran or anything else that suggests you should not get vaccinated,” said Bronx Democrat Jeffrey Dinowitz, who sponsored the bill.