Junior doctors appear to have come out on top in a bitter and long-running row with their employers over safe rosters.
The Resident Doctors Association (RDA) announced late yesterday the parties had reached a deal over the rosters.
The settlement still needs the approval of all 20 district health board (DHB) chief executives, which is expected to happen on Thursday.
It also requires ratification by junior doctors - which the union said would happen swiftly.
The deal guarantees safe working hours for doctors, with no more than 10 consecutive days at work and and fewer long nights in a row.
DHBs agreed to those changes months ago, but the talks stalled over doctors' key right to veto changes to rosters if they didn't like them.
The union said doctors had kept this right, but in exchange the contract now made it clear they would implement the rosters.
Waitemata junior doctor, Sam Holford, who was part of the doctors' bargaining team, said they got most of what they wanted.
He said a solution was reached after doctors agreed to rewriting of a clause in the contract making clear that although they retained a power of veto over rosters they may not like, they still intended implementing the new rosters.
DHBs won't comment until the deal is ratified by them tomorrow.
That will avert a further three-day strike, which RNZ understands was on the cards.
The union's general secretary, Deborah Powell, said the agreement was a relief, but trust had taken a battering during the acrimonious row.
"Both parties have to shoulder some of the responsibility there.
"We have to rebuild the trust, we have to rebuild the relationship, so that's going to be a bit of a priority, certainly for the RDA going forward."