NEW YORK (AP) — Nurses and two major hospital systems in New York City have reached a deal to end a nearly monthlong strike over staffing levels, workplace safety, health insurance, and other issues.

The tentative agreement announced Monday by the nurses’ union involves the Montefiore and Mount Sinai hospital systems. Nurses remain on strike at NewYork Presbyterian.

The walkout began Jan. 12, prompting the hospitals to scramble to hire legions of temporary nurses to fill in during a demanding flu season.

The union said members at Montefiore and Mount Sinai hospitals will vote this week on whether to ratify the contracts and return to work.

The three-year deal affects roughly 10,500 of the some 15,000 nurses on strike at some of the city’s biggest private, nonprofit hospitals.

“For four weeks, nearly 15,000 NYSNA members held the line in the cold and in the snow for safe patient care,” Nancy Hagans, president of the New York State Nurses Association, said in a statement. “Now, nurses at Montefiore and Mount Sinai systems are heading back to the bedside with our heads held high.”

The nurses’ union said the tentative agreement calls for a 12% pay raise over the life of the contract, and maintains nurses’ health benefits with no additional out-of-pocket costs.

In addition, the proposed pact includes new protections against workplace violence, including specific protections for transgender and immigrant nurses and patients, as well as provisions addressing artificial intelligence in hospitals, the union said.

Meanwhile, NewYork-Presbyterian said it agreed over the weekend to a proposal presented by mediators that includes pay raises, preserves nurses’ pensions, maintains their health benefits, and increases staffing levels. The union reiterated that the strike remains in effect at NewYork-Presbyterian hospitals.

The affected hospitals have insisted their operations are running smoothly during the walkout, with organ transplants, cardiac surgeries, and other complex procedures largely uninterrupted. Many of the medical centers, however, canceled scheduled surgeries, transferred some patients, and discharged others ahead of the strike.

The striking nurses’ priorities vary by hospital, but staffing has generally been a central issue. Nurses complained of being overworked, saying the hospitals held out for weeks on committing to more manageable patient loads. The union said Monday that the tentative agreements would increase staffing and otherwise address those concerns.

The hospitals and nurses also have been at odds over benefits, and the union sought workplace security upgrades and restrictions on the use of artificial intelligence. Hospital staffers’ longstanding security concerns flared into public view when a gunman entered Mount Sinai in November.