At a news conference, the authorities said the suspects Chiheb Esseghaier, 30, and Raed Jaser, 35, were arrested in Montreal and Toronto on Monday.
They allegedly planned to derail a VIA passenger train in the greater Toronto area. It was not clear when.
The suspects will now appear in court on Tuesday for a bail hearing.
The Royal Canadian Mounted Police (RCMP) said the surveillance operation leading to the arrests of the two suspects was “a result of extensive collaborative efforts”.
They said the two men were not Canadian citizens and were supported by “al-Qaeda elements in Iran” but there was no evidence of state sponsorship.
Their plan was to derail a train and “kill and hurt people”.
Chief Spt Jennifer Strachan said the two men had sought to target “a specific route, but not necessarily a specific train”.
At the same time, the RCMP said they believed the plot was in the planning stage and “there was no imminent threat to the general public”.
“Each and every terrorist arrest the RCMP makes sends a message and illustrates our strong resolve to root out terrorist threats and keep Canadians and our allies safe,” Assistant Commissioner James Malizia said.
The RCMP also said that America’s FBI agents were involved in the operation to foil the attack.