YILAN, Taiwan (Reuters) - The driver of a train in Taiwan that crashed killing 18 people told a court on Tuesday he had switched off its speed-control system, a court official said, as investigators pieced together events that led to the island’s worst rail crash in decades.

Rescue workers work at the site where a train derailed in Yilan county, Taiwan October 22, 2018. REUTERS/Stringer

The train came off the rails on Sunday on a curve while moving at almost 87 miles per hour (140 kmh), nearly twice the speed limit of 46 mph (74 kmh), in the island’s mountainous northeast, the head of a government investigation team said.

Chief investigator Wu Ze-cheng told Reuters earlier it was not clear whether the speed-control system, called automatic train protection, had switched off by itself or had been manually disabled before the accident, which also injured 187 people.

A spokesman for Taiwan Yilan District Court told Reuters the driver told his bail hearing he switched off the system himself to boost the train’s power when it had slowed down on an earlier stretch of the journey.

“He should have turned the system back on at the next stop,” said the court spokesman, Huang Yong-sheng.

“The defendant is highly suspected to have been negligent.”

Reuters was not able to reach the train driver, You Zhen-zhong, 48, for comment. He was granted bail of T$500,000 ($16,167) and barred from leaving Taiwan after being detained for the investigation.

You had been treated in hospital after the accident.

You’s public defender, Kou Tua-jai, said the driver knew he had to turn the protection system back on, but he had failed to do so because he was busy communicating with other coordinators due to a separate problem with the train’s speed.

“He admitted that he’s responsible for dereliction of duty, but he’d like to raise one point: there was something wrong with the train,” Kou told Reuters.

Kou said the driver said the speed shown on the train’s indicator was not its real speed.

Chief investigator Wu said more investigation was needed to determine why the driver failed to turn the protection system back on.

He said it was not immediately clear if the speed shown on the train’s indicator was different to its actual speed.

GRAPHIC: Deadly train crash in Taiwan - tmsnrt.rs/2NZiXQi

The disaster was Taiwan’s deadliest rail accident since a 1981 collision that killed 30 people.

The head of the state railway administration, Lu Jie-shen, had offered to resign but that was not accepted by the transport minister, the railway authority said.

Premier William Lai apologized for the accident on behalf of the government.

“People expected the railway to be the safest,” Lai told parliament.

“I apologize to the people on behalf of the Executive Yuan,” he said, referring to the island’s cabinet.

Train derailments are not uncommon on the island, which has rough, mountainous terrain, but deadly accidents are rare.