The conviction and 40-year prison term handed a young Canadian for plotting terrorist attacks on New York City was entirely justified, American prosecutors argue in a new appeal brief.

In addition, they reject arguments from Abdulrahman El Bahnasawy that his fair-trial rights were compromised by the judge's refusal to let him fire his legal aid lawyers.

"The imposition of a term of 40 years' imprisonment for an individual who attempted to carry out a mass-casualty terrorist attack for ISIS in New York City was not 'shockingly high, shockingly low, or otherwise unsupportable as a matter of law," the prosecutors say. "El Bahnasawy's challenge to his sentence is easily rejected."

The filing from the U.S. attorney for the Southern District of New York comes in response to El Bahnasawy's appeal of his conviction and sentence handed down by Judge Richard Berman in December 2018.

Berman's sentence was "carefully considered and well-reasoned" and took into account mitigating factors such as El Bahnasawy's youth and mental health and addiction issues, the prosecution argues.

El Bahnasawy was 17 when he met undercover agent

A 17-year-old El Bahnasawy was living at home in Mississauga, Ont., when he met an undercover FBI agent online. The defence argued unsuccessfully the agent encouraged the youth to plan attacks on the Big Apple, while prosecutors maintained the plot was well underway before the two connected.

The FBI arrested the then-18-year-old El Bahnasawy at a hotel on the outskirts of New York in May 2016. Investigators said he had bought bomb-making materials and helped secure a cabin for the purpose of building bombs.

El Bahnasawy pleaded guilty to terrorism charges in District Court for the Southern District of New York in 2016. The plans, which involved conspirators arrested in Pakistan and the Philippines, called for attacks on the New York subway and Times Square.

In their appeal in December, defence lawyers argued the sentence was inhumane. But prosecutors counter that Berman carefully and thoroughly took into account the various factors in play. In fact, the prosecution says, it was precisely because of factors such as El Bahnasawy's youth and mental health issues that Berman gave him a below-guideline sentence.

At the same time, they said, Berman recognized the "extreme seriousness" of El Bahnasawy's actions and the need to protect the public from a "radicalized terrorist."

Accused wanted legal-aid lawyers: prosecution

"That is particularly true in light of the fact that, as the reports and testimony of the defence's own experts made plain, it

was inherently uncertain whether and on what timeline El Bahnasawy would successfully rehabilitate and cease to pose a threat," U.S. Attorney Geoffrey Berman writes in the brief.

The prosecutors also defend Berman's decision to keep the public defenders on the case but also add private lawyers El Bahnasawy's parents had pushed for. The accused himself wanted the legal-aid lawyers to stay on and made that clear on several occasions, they argue.

El Bahnasawy's argument that he was deprived of his right to be represented by the lawyer of his choice simply doesn't fly insofar as he got what he wanted, they say.

"His lawyers of choice came into the case on his behalf," the prosecution says. "By keeping federal defenders in the case, Judge Berman ensured that El Bahnasawy was represented by an effective advocate at each stage of the proceedings."