Two men charged in Canada with plotting an attack on a passenger train have appeared in separate courts.

Iran has reacted angrily to police accusations that the suspects were backed by al-Qaeda elements in Iran.

Raed Jaser, 35, of Toronto and Chiheb Esseghaier, 30, of Montreal were arrested in separate raids and charged yesterday, sparking worries of a Canadian attack just one week after the Boston Marathon bombings.

Details of the hearings are covered by a publication ban.

Mr Jaser, who denied an involvement, was detained and will return for a bail hearing at a later date, his lawyer, John Norris, told reporters.

"He denies the allegations and he will vigorously defend them," Mr Norris said outside the court, describing Mr Jaser as being in a state of "shock and disbelief".

He would not disclose Mr Jaser's nationality but said he has been a resident of Canada for 20 years.

Mr Esseghaier, a Tunisian-born doctoral student at a Montreal-area university, appeared at a Montreal court.

He told the judge that conclusions had been drawn from deeds and words "that are only appearances."

Canadian authorities say they have linked the two to al Qaeda factions in Iran but they say there is no indication that the attack plans, which police described as the first known al Qaeda-backed plot on Canadian soil, were state-sponsored.

Police said they had been investigating the two suspects since last fall after a tip from the Muslim community in Toronto.

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

Canadian police said that the plot involved a passenger train route in the Toronto area.

Authorities also said the plot was not linked to last week's Boston Marathon bombings, which killed three people and injured nearly 200.

Canada's intelligence agency has long expressed concern about the possibility that disgruntled and radicalised Canadians could attack targets at home and abroad.

Police said the suspects had received "support from al-Qaeda elements located in Iran".

However, they added that there was no sign that the conspiracy, which police described as the first known al Qaeda-backed plot on Canadian soil, had been sponsored by the Iranian state.

Canada last year severed diplomatic ties over what it said was Iran's support for terrorist groups, as well as its nuclear programme and its hostility towards Israel.

An Iranian foreign ministry spokesman said al-Qaeda's beliefs were in no way consistent with the Islamic Republic, and that Iran opposed "any kind of violent action that endangers lives".

"In recent years, Canada's radical government has put in practice a project to harass Iran and it is clear that it has pursued these hostile actions," the spokesman added.