Doctors' leaders and the Government have agreed a new deal for junior doctors, with a new pay structure for working weekends and evenings.
The deal between the British Medical Association (BMA) and the Government will now be put to a ballot of medics after eight days of intense negotiations.
Under the deal, Saturdays and Sundays will attract premium pay if doctors - the vast majority of whom are expected to - work seven or more weekends in a year.
Doctors will receive a percentage of their annual salary for working these weekends - ranging from 3% for working one weekend in seven to up to 10% if they work one weekend in two.
Any night shift - on any day - which starts at or after 8pm and lasts more than eight hours, and which finishes at or by 10am the following day, will also result in an enhanced pay rate of 37% for all the hours worked.
The deal also sets out systems of payment for doctors who are on call.
This allowance is applied as 8% of basic pay over and above any weekend allowance that has been paid.
Across the board, there will be an average basic pay increase of between 10% and 11%, down from the 13% put forward originally by the Government.
There are also new agreements aimed at reducing discrimination to anyone who takes leave to care for others, such as new mothers or those on parental leave.
This includes accelerated training support to enable people to catch up, such as mentoring and study leave funding.
Some elements of the new contract, if approved in the BMA's ballot of junior doctors, will be implemented in August and all junior doctors will move on to the new terms between October and August 2017.
Health Secretary Jeremy Hunt said: "We welcome this significant agreement which delivers important changes to the junior doctors' contract necessary to deliver a safer seven day NHS.
"The talks have been constructive and positive and highlighted many areas outside the contract where further work is necessary to value the vital role of junior doctors and improve the training and support they are given.
"This deal represents a definitive step forward for patients, for doctors and for the NHS as a whole."
He also told BBC News: "Well I think it's a very positive day for NHS patients and actually for doctors as well. From the Government's point of view we've got all the red lines that we needed to improve weekend care.
"The extra cost of employing another doctor at the weekends will fall by about a third under this agreement, which will make it much easier for hospitals to improve care at weekends."
He added: "But I think we also have to reflect that this has been a very bitter dispute. There are lessons to be learned on all sides.
"I think there was a message in the industrial action that unfortunately took place that there was a lot of unhappiness amongst junior doctors about things that weren't necessarily to do with their contract, to do with the way their training operates, to do with the quality of life in those very, very tough jobs.
"And we want to engage positively and constructively to address those issues because they are the backbone of the NHS."
Dr Johann Malawana, the BMA's junior doctor committee chairman, said: "Following intense but constructive talks, we are pleased to have reached agreement.
"Junior doctors have always wanted to agree a safe and fair contract, one that recognises and values the contribution junior doctors make to the NHS, addresses the recruitment and retention crisis in parts of the NHS and provides the basis for delivering a world-class health service.
"I believe that what has been agreed today delivers on these principles, is a good deal for junior doctors and will ensure that they can continue to deliver high-quality care for patients.
"This represents the best and final way of resolving the dispute and this is what I will be saying to junior doctors in the weeks leading up to the referendum on the new contract."
Professor Jane Dacre, president of the Royal College of Physicians, said: "A way forward in this dispute was needed, both for the wider NHS and the patients we care for every day.
"We now await the outcome of the ballot of junior doctors on this proposal and hope for early resolution.
"As we have said many times before, the RCP believes that negotiations are the best way to see this dispute resolved, therefore it is welcome news that both sides have managed to reach an agreed joint proposal on the outstanding points of contention."
Danny Mortimer, chief executive of NHS Employers, said: "I am grateful to the BMA for their engagement in the process, and am pleased that by working positively together we have identified a way forward which commands their support.
"NHS Employers extends its thanks to Sir David Dalton for his leadership of our team, and we look forward to working with Dr Malawana and his colleagues in the future."
The talks were seen as a last-ditch attempt to break the deadlock between junior doctors and the Government.
The agreement to resume talks follows a wave of industrial action launched by junior doctors in recent months, which saw thousands of operations cancelled.
Junior doctors stopped providing emergency care for the first time in NHS history during their most recent walkout. More than 125,000 appointments and operations were postponed, on top of almost 25,000 procedures cancelled during previous action.
Discussions surrounding the new contract first started in 2012 but broke down in 2014.
Asked about what happened to make the agreement possible, Mr Hunt told the BBC he did not want to talk about "winners and losers".
He added: "I think what this really shows is that if we sit around the table and talk about issues that can make care safer for patients and improve the working conditions for doctors, you can have a win win, and I prefer to characterise it that way."
Asked about how he would have done things differently, Mr Hunt said: "It's very difficult because we had a manifesto commitment to a seven-day NHS that we absolutely must deliver to the British people having been elected a year ago to do that.
"But I think what we didn't understand at the start of this process was the amount of discontent amongst junior doctors about things that were not always to do with the contract, about the fact that you could be a junior doctor who's posted to Leeds and your partner is in London, and it's very, very bad for family life if you're apart for six months."
He said frustrations like that came to the surface through the industrial action, adding that the agreement will allow them to address some of those issues.
Pushed on whether or not he has any regrets about the way he handled the dispute, Mr Hunt said: "I think the way to put this is, we have to implement manifesto commitments. I could be critical of the fact that there was a very long period of time when the BMA were refusing to talk at all.
"But I think the point is that on both sides we've learned, through the process of the last 10 days, that actually talking works much better, and it is possible to end with a win win - that we can deliver our manifesto commitment for a seven-day NHS, but also make real progress in addressing some of the concerns that junior doctors have had about their working conditions, and that dialogue is the way to achieve these things, so I think it has been a very positive week."
Copyright (c) Press Association Ltd. 2016, All Rights Reserved. Picture (c) Yui Mok / PA Wire.