Another judge had thrown out the charges against 34-year-old Brandon Bostian last year, ruling that the evidence pointed to an accident, not negligence.

Pennsylvania prosecutors appealed. Judge Kathryn S. Lewis ruled that the earlier judge had erred and that there was sufficient evidence to send the case to trial.

Brandon Bostian, the Amtrak engineer involved in a fatal train crash two years ago, walks to a police station in Philadelphia on May 18, 2017.Matt Rourke / AP file

Bostian sat stunned as the decision was announced. He's free on bail but must surrender his passport. He has been on unpaid administrative leave from Amtrak since the crash.

Eight people died when the Washington-to-New York train rounded a curve at more than twice the 50 mph speed limit and hurdled off the tracks, crumpling cars and catapulting passengers into the woods. In addition to the eight deaths, about 200 people were hurt.

Federal safety investigators concluded Bostian was distracted by radio chatter and lost his bearings.

The previous judge, Thomas Gehret, echoed the thinking of city prosecutors in dismissing the case in September. City prosecutors decided not to charge Bostian, leading a victim's family to seek charges on its own as a statute of limitations loomed.

Bostian's lawyer, Brian McMonagle, said the engineer's speeding was a momentary lapse from a safety-conscious engineer who was briefly distracted.

A National Transportation Safety Board investigation completed in 2016 found no evidence that Bostian was impaired or using a cellphone.

Emergency personnel work at the scene of a deadly train wreck in Philadelphia on May 13, 2015.Patrick Semansky / AP file

Bostian is suing the government-owned railroad, alleging he was left disoriented or unconscious when something struck his train before it derailed. NTSB investigators have said nothing struck the locomotive.

He waived his right to appear at a Feb. 21 arraignment. He must call in to court officials weekly, under the terms of his bail.

Amtrak has taken responsibility for the crash and agreed to pay $265 million to settle claims filed by victims and their families. It has also installed speed controls on its track from Boston to Washington.

Pennsylvania Attorney General Josh Shapiro's office picked up the criminal case after the city district attorney's office bowed out and the family of a woman killed in the crash, Rachel Jacobs, filed a private criminal complaint.

"The victims are going to have their day in court, which is all they have ever sought," Thomas Kline, a lawyer for the family said after the ruling.

He added: "Mr. Bostian had one job and one job only on that day, which was to get the train from Point A to Point B and to carry those passengers safely. He did not do that. He has no excuse for the speeding on the tracks that day."