Negotiations started in January 2016, and have officially ended after the changes were ratified by doctors on Friday. The changes will be effective immediately, with new rosters rolling out over the coming months.
NZ Resident Doctors' Association (NZRDA) president Sara Moeke the public support during their campaign was invaluable.
"We will now have resident doctors working safer hours, which means better care for our patients and safety for the public of New Zealand."
NZRDA national executive member Sam Holford said they were "immensely grateful" to other health workers and members of the public for their support.
"I doubt we could have achieved this outcome without the immense support members of the Association received from so many people both at work and from the communities we serve.
"On behalf of all of us, thank you."
The changes bring an end to working 12 days in a row, or seven night shifts in a row.
Junior doctors went on strike twice during negotiations, walking off the job for 73 hours in January and for 48 hours in October 2016.
The strike in January led to an estimated 6000 cases of elective surgery and outpatient appointments being postponed, so that senior and non-striking resident doctors could focus on emergency and acute care.