Junior doctors have ratified a deal that settles a dispute with district health boards over rosters.
The dispute led to strikes late last year and early this year.
DHBs gave the thumbs-up to a proposed settlement weeks ago, and doctors have done the same today.
The junior doctors said it would mean they wouldn't have to work more than 10 consecutive days and no more than four consecutive nights.
A new provision will enable them to work back-to-back weekends with some rostered-off days adjoining weekends.
The strikes in October and January cost district health boards at least $5 million.
Junior doctors said they were grateful to the public for helping them get through a particularly bitter row with their employers.
Resident Doctors Association national secretary Deborah Powell said she was sorry it took such a battle to get agreement.
"The resident doctors have made a point of wanting to thank the public for their support during this dispute. It was a hard one, and they certainly feel they wouldn't have got there unless they had so much support from members of the public and their patience behind them."