Two golfers had to jump for their lives from their golf buggy to escape an oncoming train at Royal Park.

The Parkville men, aged 29 and 34, were crossing the rail lines from one side of the Royal Park Golf Course to the other when the motorised cart's wheels got stuck in the tracks at 10.37am on Saturday, Victoria Police said.

A police spokeswoman said the men riding in the cart were forced to jump out "just as the train was approaching".

"The men were uninjured however the buggy was crushed," she said.

Course manager Michael Lawn said the ride-on cart was abandoned in between the two pedestrian boom gates.