Railway workers across NSW have agreed to a new pay deal.

NSW Trains and Sydney Trains workers voted in favour of a 3 per cent pay rise for the next three years.

The postal ballot resulted in 52.8 per cent of NSW Trains employees and 50.8 per cent of Sydney Trains employees agreeing to the deal.

The fact that the vote margin was so slim is a sign that the workforce is still unhappy, union officials say.

The new EBA will now go to the Fair Work Commission for approval.

The deal follows months of negotiations and threats of strike action by rail workers.

One of the big issues that the new deal resolves relates to the staffing of a new timetable.

Unions claimed the timetables were rolled out before the workforce was prepared, leading to delays and overcrowding.

NSW Transport Minister Andrew Constance welcomed the deal, and the end of industrial action.

Mr Constance applauded the workforce for “doing the right thing by commuters, doing the right thing by tax payers and most importantly, doing the right thing by themselves by accepting a wages package which … will support them in the excellent work that they do”.

“Today's result is clear evidence that the union shouldn't have used commuters as cannon fodder.”