TAIPEI, Taiwan — The train, cruising in and out of mountain tunnels along Taiwan’s east coast, was packed with people rushing to see family and friends on the first day of a long holiday weekend.

Then, according to survivors’ accounts, it was jolted by a heavy crash, flew off the rails and slammed into the walls of a tunnel.

The derailment of the eight-car Taroko Express train on Friday morning was the worst such disaster in Taiwan in four decades, killing at least 50 people, including two train drivers, and injuring around 150 others, the authorities said.

Investigators are still trying to determine why the train crashed as it was traveling from near Taipei to the eastern coastal city of Taitung. But initial reports indicated that it had either collided with a construction vehicle that rolled down a slope onto the track, or was hit by the falling truck just as it passed.

By Friday evening, rescue workers had freed dozens of passengers who had been trapped in the wreckage, but were struggling to get to several train cars that were deep inside the tunnel. Local news footage showed one worker using an electric circular saw to cut through one of the twisted carriages.

Video footage posted online showed rescuers carrying injured passengers out on stretchers as other survivors emerged from the tunnel walking on the roofs of the train’s cars, some rolling suitcases. Several passengers described smashing the windows of the carriages with their luggage to escape.