It will also mean an end to the Sunday strikes which have seen most ScotRail trains cancelled since March.
The union said a 2.5 per cent, one-year increase backdated to April had been agreed.
It had proposed the deal minutes before ScotRail’s 5pm deadline for accepting its previous offer.
The settlement also includes three hours’ extra pay for rest day working (days off) and a £300 COP26 payment.
ScotRail had offered a two-year deal, tied to productivity improvements, of 2.5 per cent this year and 2.2 per cent from next April.
The RMT said the settlement agreed did not include any of the proposed productivity changes, such as more use of digital technology and fewer face-to-face briefings.
However, the deal is significantly less than the demand for a one-year, 4.9 per cent increase made by the RMT in an interview on BBC Scotland yesterday.
The RMT had called 12 days of strikes from Monday to coincide with the United Nations’ Conference of the Parties summit.
They were likely to have caused major disruption because ScotRail had said it would only have been able to run services on a secondary Edinburgh-Glasgow line, and a shuttle to the conference venue.
An industry source said: “The RMT was demanding 4.9 per cent yesterday, so a good outcome for passengers, staff and taxpayers.
"The days of above inflation pay rises are over.
"ScotRail revenue is still 50 per cent of that pre-pandemic.”
However, RMT Scottish organiser Mick Hogg told The Scotsman: “This meets my members aspirations and delivers fairness and justice."
General secretary Mick Lynch told union members: "By accepting the offer, ScotRail stated that it would mean all current disputes between your union and the company would be resolved and that all current and planned industrial action would be withdrawn immediately.
“I can advise you that the offer was put to your union’s AGM tonight and was accepted unanimously by delegates.
“The AGM congratulates you and I congratulate you on achieving this magnificent industrial victory and gaining a one-year pay deal and Rest Day Working Agreement without any preconditions and which banishes the previously stated productivity strings attached.”
ScotRail chief operating officer Ian McConnell said: “We have reached a pay agreement with the RMT trade union that resolves strike action.
“We look forward to Scotland’s Railway [ScotRail and Network Rail Scotland] playing its part in delivering a successful COP26 next week.”
Scottish Labour transport spokesperson Neil Bibby said: “This is very welcome news.
“This eleventh hour deal may help the SNP save face but it won’t fix the mess they’ve made of our railways.
“However welcome the pay deal is, it doesn’t undo the contempt the SNP have shown rail workers over the last two years.
“It is disgraceful that it took the risk of embarrassment at COP26 to convince the SNP to give rail workers the fair pay they deserve.
“Scotland’s railways are not just for COP26.
"The SNP must now commit to building a railway that is truly fit for purpose and stopping the reckless cuts to services."
Scottish Transport Minister Graeme Dey said: “Following recent discussions we are pleased that all four trade unions have now agreed to accept this very good pay offer on behalf of their members.
"We are proud to have brokered and funded a deal which gives Scotland’s rail workers a decent pay rise and improved terms and conditions, in contrast to conditions for rail workers under the UK Government.
“We are also pleased that the RMT reached out to restart discussions based on the offer that had been made to them on Sunday. Now an agreement has been confirmed the strike action will thankfully now come to an end.
“As well as getting the pay rise they deserve, railway workers can now go back to delivering rail services for people right across Scotland and as well as for those attending COP26. Allowing everyone who works in Scotland’s Railways to play their part in welcoming the world to our country and showcase our efforts towards building a greener, cleaner railway.”