Last month, President Trump rolled back an Obama-era rule that said employer health plans must cover birth control at no cost to women. The new rule, widely described as "gutting" the birth control mandate, allows an employer to opt out if they have a religious or moral objection.

On Monday, Massachusetts became the first state to counter the Trump administration's policy change with a new law. The measure sailed quickly and easily through the state Legislature over the last two weeks and was promptly signed by Republican Gov. Charlie Baker on Monday afternoon.

It not only cements into place the Obama-era mandate for free birth control, encoding it into state law, but goes a step further and expands coverage.

"I'm hoping today's announcement gives women confidence that contraceptive coverage will be protected here in Massachusetts," said Lora Pellegrini, who leads the Massachusetts Association of Health Plans. "And that women can sleep better tonight knowing that they will still have access to these important birth control methods."

Gov. Charlie Baker signs the ACCESS bill at the State House Monday. (Courtesy of the governor's office)

Pellegrini said other states are debating how to ensure birth control coverage.

"I think there's a real opportunity here for Massachusetts once again to lead, because we have a unique agreement here," she said. "I think it's the first in the country where Planned Parenthood, NARAL and some of the other organizations came together with the health insurers to find a common-sense approach."

That "common-sense approach" developed over many hours of negotiations that sometimes looked like they might break down, say participants. But they kept trying, seeing imminent threats to birth control coverage in Republican efforts to repeal the Affordable Care Act and Trump's efforts to undo Obama-era rules.

"I think when you enter into negotiations with insurers who understand the public health benefits of birth control, you're able to hammer out a compromise," said Rebecca Hart Holder, executive director of NARAL Pro-Choice Massachusetts. "There were moments when I didn't think it would happen. But we hung in there and stayed at the table."

As did the insurers, whose focus on controlling costs and keeping plans flexible often puts them at odds with advocates who want new coverage mandates.

The key, Hart Holder said, "was really not being afraid to have strange bedfellows when pushing for reproductive freedom."

The law takes effect immediately but health insurers have six months to bring changes fully into effect. It affects women who have commercial insurance — on their own or through an employer — but not those whose employers are so big they insure themselves, and thus are subject to federal rather than state mandates, Pellegrini explained. But, she said, the law's backers hope self-insured companies will adopt its rules as well.

Among the ways the law expands coverage:

• Insurers in most cases must cover a full year of birth control pills at a time. Currently, women often have to go back to the pharmacy every three months or less.

• Insurers must cover more types of birth control.

• Emergency contraception — the so-called morning after pill -- must be covered without a prescription.

And among the compromises that advocates and insurers say they made:

• The birth control advocates wanted the 12-month pill coverage, but the insurers worried about waste if a certain type of pill turned out to be a poor fit. They compromised that the first time a woman tries a type of pill, only three months should be covered, and then, if the pill works well for her, the full 12.

• The advocates wanted vasectomies mandated, but surrendered on that one and said they will come back to it. (Pellegrini said most Massachusetts plans cover vasectomies anyway.)

• The advocates wanted prescription-free emergency contraception and the insurers came up with a mechanism to make it possible: using a "standing order," as pharmacies do with flu shots.

"We're setting an example," said Elana Margolis of Blue Cross Blue Shield of Massachusetts. "We're showing how differing thoughts and opinions can come together and find common goals, and we're saying we're willing to move first, fast, and frankly, furiously, to get it done."

Will other states follow? NARAL's Hart Holder said she's heard from distant colleagues interested in emulating the Massachusetts law. About a dozen other states have already passed bills shoring up aspects of their birth control coverage in case the Affordable Care Act is repealed, she said.

Senate Majority Leader Harriette Chandler, who co-sponsored the bill, can remember when birth control was controversial, she said. No longer.

"We've really come almost 180 degrees around on this issue in my years in the Senate, in my years in the Legislature," said the Worcester Democrat. "I've seen it happen. People feel strongly about this. They want contraception. They want to be able to get the best health care possible, and they felt very strongly about it."

She pointed out that virtually all the leaders of insurers and advocacy groups who backed the bill were women.

But their male colleagues did not need much arm-twisting, said Dr. Jennifer Childs-Roshak, who leads Planned Parenthood in Massachusetts, because when you talk about access to birth control, everybody has a story.

"How they almost missed filling their prescription," she said, "or they had to run to the pharmacy at the last minute to pick up their girlfriend's birth control pills, or they had a condom break and needed emergency contraception. So this is something that really resonates with people across the board."

The Catholic Action League is on record opposing the measure, but no one testified against it at a hearing last month, say advocates who were there.

"It was handed to us on a silver platter," Sen. Chandler said.

Said Margolis of Blue Cross Blue Shield: "All the stars were aligned to make this happen. It was the right time, and the right thing to do."