Two men are accused of jumping out of a truck seconds before it collided with a moving train in what Mounties are calling a "foolish stunt."

Police say the 21-year-old driver from Chilliwack and 23-year-old passenger from Agassiz drove the truck onto the railway tracks near the Cameron Road and Wells Road crossing.

They then allegedly drove towards the train, abandoning the vehicle just in time to avoid being crushed inside it.

A witness brought the fleeing occupants back to the scene of the crash where they were questioned by police.

Mounties, firefighters, and paramedics arrived on scene to assess the situation.

"This stunt was time consuming for police as well as CP Rail workers," Cpl. Tammy Hollingsworth said in a statement.

"It disturbed the trains from transporting goods, which is extremely costly to CPR for having to shut down and repair the tracks."

Police believe alcohol was a factor in the incident.

The men suffered no injuries during this stunt, but were issued violation tickets for failing to remain at the scene of the accident, failing to obey a traffic control device and for driving contrary to restrictions.

The driver received a 90-day driving suspension and his crashed vehicle was towed.

The investigation is ongoing and Agassiz RCMP say further charges against the men are possible.