At least 22 ScotRail services between Edinburgh and Fife, Perth and Arbroath were cancelled following the incident, understood to be a fatality, at around 2pm.
A further nine services, including between Edinburgh and Aberdeen and Inverness, were disrupted, with some terminated or delayed.
ScotRail’s JourneyCheck service said: “Due to the emergency services dealing with an incident between Dalmeny and Inverkeithing.
“All lines are closed.
"Disruption is expected until 5pm.”