The undercover FBI agent who stopped an al-Qaeda terrorist plot to derail a Via Rail train near Toronto has gone public, saying a Canadian decision to wrap up the investigation cost U.S. intelligence agencies the opportunity to catch a suspected terrorist sleeper agent in their country.

The agent recently spoke to the CBC's The Fifth Estate in an exclusive Canadian television interview. The full interview will be broadcast this Friday on CBC Television. The agent has also written a book about the operation, American Radical, which will be published soon.

"There hasn't been a day that I've woken up since the end of this investigation where I have not thought about the American sleeper. He was not captured during this investigation," he told The Fifth Estate in an interview in New York.

"My job is to protect innocents from those that mean harm to them. And I didn't get everyone."

The agent is going by his cover name from the operation, Tamer Elnoury, to protect his identity. He's still an active undercover agent.

Posed as American real estate magnate

Elnoury is among the small number of highly valued, Arabic-speaking Muslim agents doing undercover counterterrorism work for the U.S. Federal Bureau of Investigation.

American Radical traces his involvement in the investigation that led to terrorism convictions and life sentences in 2015 for Chiheb Esseghaier, a Tunisian citizen doing doctoral research in Montreal, and Raed Jaser, a stateless Palestinian who had come to Toronto as a teenager with his family.

Esseghaier "popped up on the FBI's radar" after he made contact with some al-Qaeda operatives online, Elnoury writes. The FBI alerted Canadian officials, who opened their own investigation.

Esseghaier had travelled to Iran twice in two years, arousing concern he was there for terrorist training.

Canadian intelligence tried to "bump" Esseghaier — stage a casual meeting that seemed random — during a 2011 conference in Mexico, the book says. "The Canadians didn't have a Muslim, so they used a Peruvian Christian. Chiheb's English wasn't that good. The hope was a native Arabic speaker would have a better chance."

Elnoury posed as a globe-trotting American real estate magnate who despised Western ways and funnelled his profits to his overseas uncle, a financier for al-Qaeda.

Fishing trip became mission to scout targets

In June 2012, Elnoury managed to ensure he and Esseghaier were seated together on a flight to California. They quickly became friends and Esseghaier was soon openly talking about shooting down planes with a portable missile launcher, the book says. Elnoury believes Esseghaier saw him as a like-minded ally with the money to help fund his operations.

Early that September, Elnoury, who had become close to Esseghaier, was called to a meeting in New York. A senior Canadian Security Intelligence Service (CSIS) official had flown in to hear what Elnoury knew about Esseghaier's plans to go fishing with someone.

Elnoury scoffed at the notion the intense Tunisian would ever go fishing, and advised that Esseghaier "is here to hurt us."

CSIS learned the fishing trip turned out to be a mission with Jaser to scout a railway bridge they planned to sabotage, sending a train that travels from New York to Toronto hurtling into the river below, killing many passengers.

The file, now a criminal matter, was handed to the RCMP and Elnoury was enlisted to gather evidence. He paid a visit to his friend in Montreal.

Elnoury portrays Esseghaier as zealously devoted to the extremist cause, but also someone who had a crush on a female colleague and enjoyed eating lobster and stopping at Tim Hortons.

Worries arrests would mean American would escape

During a drive to Toronto to meet Jaser, Esseghaier confided details of the operation: al-Qaeda planners in Iran had ordered him to cut a hole in the train tracks. He and Jaser would use jackhammers to cut the track, while Elnoury would be needed to act as lookout.

Esseghaier told Elnoury he emptied his bank account in the spring of 2011, buying a one-way ticket to Tehran and planning to drive to Afghanistan, where he would die in battle. But in Zahedan, a town in southeastern Iran, he was recruited by al-Qaeda. He returned the next year for training and was briefed on the train plot.

Esseghaier also said something that made Elnoury's heart race: there was a "soldier" in the U.S., an al-Qaeda sleeper agent known as Al-Amriki, the American. Esseghaier expected to meet him one day.

"We needed to rethink the case," Elnoury writes. "Chiheb was our only link to the American sleeper. There was no way we could arrest him before we identified the other sleeper."

Planning for the train attack continued. But Elnoury pressed Esseghaier about meeting the sleeper. A key Iranian contact finally agreed it would be a good idea, and invited Esseghaier and Elnoury for a talk in Dubai.

Elnoury wanted to go, but he was skeptical the Canadians would let Esseghaier travel overseas at this point. In April 2013, Eric Holder, then U.S. attorney general, flew to Ottawa to discuss the Dubai idea, the book says.

However, the RCMP executed arrest warrants, ending the operation. Elnoury understood the decision. The rail plot case was over. And just a week earlier, bombs had exploded at the Boston Marathon, killing three and injuring hundreds.

"Everyone was on edge," he writes. "No one wanted to let a terrorist slip out of our grasp."

But mostly Elnoury was angry. "I felt like the Canadians and the FBI wasted all of our hard work."

Elnoury did not consider the arrests a victory. "Best case, we tried. But really you could say we failed," he writes.

"Chiheb was a lot of things, but he was never a liar. Personally, I have no doubt that there was an American sleeper."

You can watch the Fifth Estate's story Terror Plot in Canada: The Inside Man on Friday at 9pm on CBC TV.