Three days after going on strike, more than 7,000 nurses at two New York City hospitals will return to work after reaching tentative contract deals early Thursday that would increase their pay and improve their working conditions, union leaders said.

The nurses reached agreements with the two hospitals — Mount Sinai Hospital in Manhattan and Montefiore Medical Center in the Bronx — to improve patient-to-staffing ratios, the New York State Nurses Association, which represents more than 42,000 members, said in a statement on Thursday. For nurses at Montefiore, the tentative deal would include a 19.1 percent wage increase, the creation of more than 170 new nursing positions and health care coverage for eligible nurses.

“Through our unity and by putting it all on the line, we won enforceable safe staffing ratios at both Montefiore and Mount Sinai where nurses went on strike for patient care,” said Nancy Hagans, the president of the union, in the statement. “Today, we can return to work with our heads held high, knowing that our victory means safer care for our patients and more sustainable jobs for our profession.”

Mount Sinai and Montefiore said in separate statements that they welcomed the agreements with the union. “It is fair and responsible, and it puts patients first,” said Mount Sinai.

Philip O. Ozuah, the chief executive of Montefiore Medicine, said the hospital was, “grateful for the dedication and commitment of our nurses who have served through very challenging circumstances over the past several years.”

The hospitals had diverted ambulances, canceled elective procedures and discharged patients in anticipation of the labor action, the largest nurses strike in New York City in decades. It began on Monday morning after the hospitals and union failed to reach a deal following four months of contract negotiations.

After the strike began on Monday, Montefiore called in temporary nurses, and the mayor asked people to dial 911 only when necessary. While the emergency room waiting area was mostly empty this week, conditions inside the hospital were “chaotic,” some patients and staff said, as medical residents and other staff were pressed into service to do nursing duties.

The main sticking points in the negotiations at both Montefiore and Mount Sinai had been staffing: Nurses had asked the hospital administrations to attract and hire more nurses and reduce patient-staff ratios to improve working conditions and patient safety.

Nurses in the intensive care units at both hospitals said they had been routinely asked to care for three critically ill patients at a time, even when patients should have received one-on-one care. In packed emergency rooms, nurses described being asked to care for 15 patients at once in chaotic conditions.

“We are leaving the profession in droves because we go home with moral injury,” said Benny Mathew, a Montefiore emergency nurse for a decade, before the end of the strike was announced. “We go home crying because we are not able to meet the needs of our patients.”

Kavita Paltoo, 36, works in the stroke unit and has been at Mount Sinai for six years. She described double and even triple loads for nurses in ICU and critical care units, and said typically works 14 hour shifts with no lunch breaks.

“We’re literally just giving medication and moving to the next patient,” she said. “We’re not providing quality of care. We’re not able to listen to the patient.”

Téa Kvetenadze contributed reporting.