A former Canadian resident who was arrested in connection with an alleged terror plot to attack a Via Rail train was sentenced Wednesday in New York to the 15 months he has already served after the case against him fizzled.

Ahmed Abassi, 27, who had been studying engineering at Laval University before his 2013 arrest in New York, pleaded guilty last month to less serious immigration charges.

The Tunisian national was originally accused of plotting to organize a U.S-based terrorism cell and prosecutors alleged he radicalized Chiheb Esseghaier, a fellow Tunisian national who was doing doctoral research on nanosensors in Quebec.

But Abassi's lawyers argued in sentencing documents that though Abassi expressed some radical ideas, he was actually resisting Esseghaier.

Lawyer Sabrina Shroff contended that Esseghaier was unable to convince Abassi to participate in his alleged plans, becoming so frustrated by Abassi's refusals that he branded him as "useless to the cause" and "not a true Muslim."

Abassi first came to the attention of Canadian authorities investigating Esseghaier, U.S. prosecutors wrote in their sentencing documents.

"U.S. and Canadian law enforcement had long been aware of Esseghaier's plots, and Esseghaier was under round-the-clock surveillance," prosecutors alleged.

Esseghaier and Raed Jaser, a permanent resident of Palestinian descent, are expected to go to trial early next year in Toronto on terrorism charges relating to an alleged plot to attack a train travelling between the two countries. Esseghaier is self-represented, but Jaser's lawyer has denied the allegations against his client.

Abassi's Canadian student visa was revoked while he was visiting Tunisia because he became a target in the Esseghaier investigation, prosecutors wrote, though Abassi didn't know the reason at the time.

It was his attempts to get back to Canada to continue with his studies and reunite with his wife -- who he met at Laval while she was a PhD student in electrical engineering -- that led Abassi to commit the immigration offences, Shroff argued.

U.S. prosecutors also note Abassi's unwillingness to fall in with Esseghaier's alleged plans, but argue that Abassi refused to participate "for the wrong reasons."

"One reason Abassi gave for not participating was that the number of American casualties from such an operation would be too few," prosecutors wrote. "For example, Abassi described 50 or 100 casualties as 'something light.' Later in the conversation, Abassi said he had 'a principle, the principle that America should be wiped off the face of the Earth."'

Though there is no dispute that Abassi "repeatedly" and "emphatically" refused to join Esseghaier's alleged plot and only committed the immigration crimes "in part" because he wanted to return to his wife in Canada, his views suggest he is "far more dangerous" than a simple immigration fraudster, prosecutors contend.

People in the U.S. are not jailed for their thoughts, Abassi's lawyer noted.

Moreover, those thoughts are the product of an undercover FBI agent who was introduced to Abassi in the fall of 2012 as a businessman. The agent then ingratiated himself to Abassi, cultivating a relationship and trying but failing to groom him to become a terrorist, Abassi's lawyer says.

"It should be clear at the outset that to the extent Mr. Abassi now has extremist views the government is largely responsible for them," Shroff wrote.

"Whatever Ahmed may have said to please the man he viewed as his protector, sole support, and best hope, those words were never, ever followed by any improper action or even a plan for an improper action."

Abassi is a student who "talks incessantly, enjoys being a contrarian and arguing, but who is steadfast in his refusal to do anything -- big or small -- to harm others," Shroff wrote.

"If Ahmed was really such an extremist (rather than a young man placed in a desperate position by the U.S. and Canadian governments who said things to please the undercover agent, Ahmed's sole means of support and hope to return to Canada), Ahmed would have acted, and this would be a terrorism case. It is not, and the Court should not treat it like one for sentencing purposes."

Abassi and his wife were married in August 2012 in Quebec City, five months after they met at Laval, she wrote in a letter to the sentencing judge. Since they were both from Tunisia they decided to travel there for a second wedding that December, Yousra Ben Msallem wrote.

The agent constantly called and emailed Abassi, even while the couple was in Tunisia, Msallem wrote. Then when Abassi's visa was revoked the agent convinced Abassi to join him in New York because he could help Abassi get a Canadian from the U.S., Msallem wrote.

"He convinced my husband that the only way he could go back to Canada was to first come to America," she wrote. "That is the only reason Ahmed go to New York. Not for terrorism."

The agent put Abassi up in a luxury apartment in New York and treated him to fancy meals, leaving Abassi feeling guilty and indebted to the agent, his wife wrote.

Also during that time Abassi's brother was in a serious car accident that left him in a coma. The agent sent the family hundreds of dollars to help with related expenses, Abassi's lawyer wrote.

During Abassi's stay in New York he "frequently" met with Esseghaier and the agent, and during those conversations Esseghaier told Abassi "about his intent to attack Americans and Canadians inside the United States and Canada," prosecutors alleged.

Though Abassi did not join Esseghaier's alleged plot, he did talk about wanting to send money to a terrorist group in Syria, prosecutors wrote. Abassi applied for permanent residency in the U.S. after the agent told him it would allow him to travel throughout the world to recruit like-minded "brothers," prosecutors wrote.

Abassi listed his occupation on the paperwork as property manager, which formed the basis for one of the two immigration offences. The other was that he told immigration authorities upon his arrival in New York that he planned to work for the agent's real estate company.

Abassi "deeply regrets" lying to immigration authorities, but without the involvement of the undercover agent, he would not have tried to enter the United States or apply for a visa there, his lawyer argued.

"Without (the agent), Ahmed would have been, at worst, an unhappy but free man living in Tunisia," Shroff wrote.

With files from The Associated Press