Massachusetts Gov. Charlie Baker on Monday signed a bill that would mandate all employers cover birth control regardless of religious or moral objections, pushing back at rules that were activated at the federal level.

Baker, a Republican, said on Twitter Monday that his signing of the bill, which was passed along bipartisan lines in the legislature, would ensure "critical access to important contraceptive coverage." The law goes into effect immediately, but insurers have six months to implement changes.

The law in Massachusetts would run counter to federal regulations issued in October, in which the Trump administration rolled back an Obama-era rule that required employers to opt out of birth control coverage each year if they have religious objections. Preventive care for women is required under Obamacare, but the administration, through the Department of Health and Human Services, has discretion about what falls into that category.

If an employer does not have a religious or moral objection, the federal law allows for women to access a wide range of birth control, from intrauterine devices to birth control pills, without any cost to them. Some employers object to all types of birth control while others object specifically to IUDs and emergency contraception, which they liken to an abortion because their labels say they can prevent a fertilized egg from implantation.

The mandate under former President Barack Obama was attacked by critics as an assault on religious liberty, and in the case Burwell v. Hobby Lobby the Supreme Court held that it violated the Religious Freedom Restoration Act of 1993. The Obama administration was steered by the justices to come up with a more narrowly tailored rule, which has been revised by the Trump administration. HHS said that it expected few women would be affected, noting that 200 employers had sued under the former rules.

The latest rules, however, also have generated lawsuits from states. Individual employers have vowed to continue to provide coverage for a range of birth control regardless of the opt-out provision.

The Massachusetts law goes even further than the federal government did under Obama because it allows birth control pills to be covered for a year.

Planned Parenthood urged other states to pass similar legislation.

“Birth control coverage is still at risk for women nationwide under the Trump administration," said Cecile Richards, president of Planned Parenthood Action Fund. "We need everyone — lawmakers on both sides of the aisle, business leaders, artists — to follow Massachusetts’ lead and take action."