Workers have voted overwhelmingly to accept pay offers from train companies and Network Rail.
Members of the Rail, Maritime and Transport union (RMT) backed a one year rise of 4.5% at Network Rail (NR) and increases at train operators of 4.75% for the last year and 4.5% for 2024/25.
Almost 99% of train company members voted in favour while NR workers backed their pay rise by 88%.
The RMT said the ballot results mean that the long-running national rail dispute is now over.
A statement said: "This outcome reflects the collective efforts of our membership in defending their jobs, working conditions, pay, and pensions from the attacks of the previous Tory government and their private contractors.
"We thank our members for their efforts during this long but successful campaign.
"Their resolve has been essential in navigating the challenges posed during negotiations and in particular the previous Tory government's refusal to negotiate in good faith, alongside relentless attacks by sections of the media and the employers.
"RMT remains focused and committed to supporting public ownership as a path to building a stronger future for the rail industry for both workers and passengers."
It brings an end to a two-year dispute which has caused widespread disruption to the country's transport network.
The RMT agreement comes after train drivers with the Aslef union last week voted overwhelmingly to accept a multi-year pay deal, ending a two-year dispute at 16 rail companies.