Ontario’s highest court has granted a new trial for two men who were found guilty of terrorism charges after being accused of plotting to derail a Via Rail passenger train in the Greater Toronto Area.

The Court of Appeal for Ontario ordered Tuesday that the 2015 convictions of Raed Jaser and Chiheb Esseghaier be set aside.

A new trial was ordered.

The pair had argued in court earlier this year that the judge who oversaw the case made several errors, including in rejecting their request as to the method of jury selection.

Jaser and Esseghaier were found guilty in 2015 on a total of eight terror-related charges between them. They were originally sentenced to life in prison with no chance of parole until 2023.

The men were arrested in 2013, following a cross-border investigation that involved Canadian and American law enforcement.

RCMP said at the time the two accused were plotting to derail a passenger train. Police said in 2013 that the two men watched trains and railways in the Greater Toronto Area.

The Toronto judge who presided over their trial found both men had not renounced their extremists beliefs, nor had they accepted responsibility for their offences.

Police said in 2013 that Jaser and Esseghaier were getting “direction and guidance” from al-Qaeda elements in Iran.