A Canadian who was convicted of plotting a terror attack targeting Times Square and the subway system in New York City is asking a judge for a second chance ahead of a sentencing hearing in April.

In a 24-page handwritten submission before his sentencing, Abdulrahman El Bahnasawy said frustration with how the West treated Islam turned him toward extremism.

The 20-year-old, a Mississauga, Ont., resident, described anger at the U.S. and its allies for "disrupting our life and murdering our civilians with reckless airstrikes..." writing later that it was appropriate to use similar methods back. He wrote he was not trying to justify his actions, but just wanted to explain his thought process at the time.

He was 18 when he was arrested in New Jersey on a family trip, accused of conspiring to attack New York City in the name of the Islamic State in Iraq and Syria (ISIS).

Agent communicated with Canadian, 2 others

El Bahnasawy had shipped bomb-making materials to a contact in the U.S. who turned out to be an undercover FBI agent. The agent had been communicating electronically with El Bahnasawy and two others in the months leading up to the failed attack.

Two other men — Talha Haroon, a 19-year-old U.S. citizen living in Pakistan, and Russell Salic, a 37-year-old Philippine citizen — were arrested outside of the U.S. for the plot.

El Bahnasawy pleaded guilty to numerous terrorism charges in October 2016, but his case was sealed for a year until the other two suspects were arrested.

'I want a stable life,' El Bahnasawy wrote by hand in a 24-page letter submitted to New York City Judge Richard Berman. (CBC)

In his letter to the judge, El Bahnasawy apologizes for his behaviour, writing, "I want to experience life away from drugs and away from war and violence."

He describes growing up in Kuwait feeling isolated because of his Egyptian heritage and that after moving to Canada, he became enamoured with and eventually addicted to drugs. Letters from his parents describe various ways the family attempted to get him help, including moving back to the Middle East and seeking treatment at the Centre for Addiction and Mental Health (CAMH) in Toronto. There was also a trip to a psychiatric hospital and another rehab facility along the way.

But El Bahnasawy relapsed after months at CAMH and his family sent him to an Islamic school, where, he describes in the letter, how initially, he didn't identify as a Muslim, but soon became interested in the religion.

El Bahnasawy, shown on his Facebook profile in October 2015, handed in the 24-page letter ahead of his sentencing next month. (Facebook)

El Bahnasawy describes his realization that "Islam would fix all the problems in society or the world in general, and that its system and lifestyle would have prevented the life I lived."

He doesn't go into detail about the plot he was convicted of or his interactions with the undercover agent, except to describe a time when he forgot the code he used to talk to his contacts and thought it was a message from God to walk away. He eventually remembered he had written it backwards.

"I wonder where my life would be if my memory just hadn't worked that day," he writes to Judge Richard Berman.

Lawyers argue for release

In their submissions, his lawyers argue that El Bahnasawy was not a hardened and trained ISIS fighter, but a socially isolated teenager, struggling with self-esteem issues, who was arrested three days before an appointment with a doctor to seek further treatment.

His lawyers wrote that his turn towards violence and extremism came during "a pause in treatment and prescribed medications."

"We think he should be set free and allowed to go home — he was an 18-year-old that Canada could have and should have saved," his legal team said in a statement to CBC. "Instead, Canada handed him over to the United States and the United States should let him go home."

They say he has a long history of mental illness and a long battle with drugs. Both El Bahnasawy and his lawyers describe difficult conditions he has faced while in the U.S. prison system.

He faces the possibility of life in prison. His sentencing hearing is scheduled for April 9.