Teenagers risked derailing a train by putting a wheelie bin in the middle of a railway track in Carnoustie.
One of the boys then stood on the tracks to film the impending crash.
British Transport Police is now investigating the potentially deadly trespassing incident following reports of two young men risking their lives on the line.
Carnoustie Independent councillor Brian Boyd said: “This could have been catastrophic.
“This is the latest in a long line of anti-social behaviour issues in the town of late and I have raised this with senior police officers.”
Officers were scrambled to the Anderson Street private crossing in Carnoustie on Thursday at around 7pm after the teenagers climbed over the fence and put a wheelie bin on the line.
One boy stood in the middle of the tracks to film the train approaching but the driver of the Edinburgh to Aberdeen service slowed down before impact.
The driver had already been told there might have been an issue ahead after the teenagers were spotted on the tracks by a driver going the other way and he pulled to a stop when he saw the light from a mobile phone shining in the distance.
The train was delayed by 20 minutes while the wheelie bin was removed from the tracks and the teenagers jumped back over the fence – with one losing a shoe in the melee.
Carnoustie SNP councillor Mark McDonald said: “The reports of teenagers on the track at Carnoustie is deeply concerning and their actions go far beyond anti-social behaviour.
“Trespassing on a railway line is incredibly dangerous, not only putting their lives in danger but also putting passengers and staff on the train at risk.
“Had it not been for the swift actions of the British Transport Police and the skill of the train driver this incident could have been much more serious.”
Mr McDonald said putting a wheelie bin on the track was “frankly incomprehensible”.
A spokeswoman for British Transport Police said: “Officers were called to Carnoustie station at 7pm on Thursday following reports of two trespassers on the line.
“BTP quickly attended but two young men had left the scene. A wheelie bin was removed the tracks. Enquiries are currently ongoing.
“Officers would encourage anyone who saw what happened or has any information to contact them by texting 61016 or calling 0800 40 50 40 quoting reference 567 of 21/02/19.”
A spokesman for Network Rail said: “There was a trespass incident in Carnoustie at around 7pm on Thursday night.
“Two trespassers were reported by a driver and BTP attended. The two individuals ran off before police arrived.
“The incident caused delays to the Edinburgh-Aberdeen train that was in the location at the time.”
In 2012 a packed commuter train in Lancashire narrowly avoided being derailed after crashing into a wheelie bin.
The bin became lodged under the train following the ‘mindless’ incident and was dragged along as the terrified driver slammed on the brakes.