A quick-thinking Sydney Trains worker averted disaster on Saturday when a 40-wagon freight train lost its ability to brake as it hurtled towards Unanderra, near Wollongong.

The Australian Transport Safety Bureau (ATSB) is investigating the incident on the Moss Vale to Unanderra line.

The alarm was raised just before 1pm, when the privately-owned train, carrying grain, reported braking issues at Dombarton, north-west of Dapto.

Sydney Trains' Rail Management Centre was alerted to the problem and staff acted quickly to divert the train to an uphill siding yard.

"Sydney Trains' signallers stopped all other nearby freight and rail services, and diverted the train to a siding yard at Unanderra, where it was able to safely stop," a Sydney Trains spokeswoman said.