BOSTON — A new Massachusetts law signed Thursday by Republican Gov. Charlie Baker assures that women won’t be forced to choose between a healthy pregnancy and keeping their jobs, according to advocates for working women.

The measure approved by the Legislature requires employers to offer “reasonable accommodations” to pregnant workers and makes it illegal to fire or refuse to hire a worker because of her pregnancy.

Accommodations could include anything from temporary transfers to less strenuous positions, to providing workers with a stool to sit on or more frequent bathroom breaks.

It would also require employers to provide time and private space for nursing mothers to pump breast milk.

Baker suggested the rules were “long overdue,” adding they would help expectant and working mothers support their families and raise healthy children.

Among those attending the signing ceremony at the Statehouse was Alejandra Duarte, who in April testified before a legislative committee about how she lost her baby at 19 weeks after working grueling 10-hour shifts at an industrial laundry in Worcester.

After becoming pregnant, Duarte said she requested that she temporarily be given less strenuous duty. Instead, she recalled, her supervisor gave her longer shifts and more responsibilities, which included pushing 600-pound laundry carts.

In an interview after Thursday’s ceremony, Duarte said she hopes the new law would assure that no other woman suffers as she did.

“It feels that from so much pain something good came out of it,” she said. “From now on, women will have more protections and be able to stay working and provide for their children.”

Democratic Sen. Joan Lovely, a co-sponsor of the bill, said women like Duarte “should not have to choose between having a healthy pregnancy and earning an income for her family.”

Democratic House Speaker Robert DeLeo made the bill a priority for this legislative session after MotherWoman, a Hadley-based advocacy group for working women, negotiated an agreement with Associated Industries of Massachusetts, an organization that represents employers, on proposed language in the bill.

Businesses could seek an exemption from the law, which takes effect next April, if they could prove compliance would result in an “undue hardship.”

At least 18 other states have similar protections for pregnant workers, backers of the measure said.