Image copyright Getty Images Image caption A VIA Rail passenger train leaves Toronto's Union Station.

A Canadian court has ordered a new trial for two men convicted of terror charges over a plot to attack a train from New York to Toronto.

Raed Jaser and Chiheb Esseghaier were arrested by Canadian authorities in April 2013.

They were found guilty in 2015 on charges including conspiracy to commit murder for the benefit of a terrorist group.

Those convictions have now been aside due to an "error" by the trial judge.

On Tuesday, an Ontario appellate court judge issued a ruling directing a fresh trial for the pair, arguing that the jury in the trial had been improperly selected.

Jaser, 41, a Palestinian from Toronto, and Esseghaier, 36, a Tunisian from Montreal, appealed against their conviction and sentencing in February.

They cited a number of errors including the rejection of a request they had made regarding jury selection.

The two were arrested following a joint surveillance operation by the Royal Canadian Mounted Police and FBI agents from the US.

They were alleged to have spent months plotting to kill as many people as possible on the VIA rail passenger train route.

US officials said at the time that the attack would have targeted a rail line between New York and Toronto, a route that travels along the Hudson Valley and enters Canada near Niagara Falls.

VIA Rail operates passenger rail services across Canada and carries nearly four million passengers annually.

During the original trial the prosecution alleged that Jaser and Esseghaier had been motivated by Islamist extremism and they were both sentenced to life in prison without chance of parole until 2023.