A young man who wanted to be an Islamic State fighter but was stopped at Sydney airport as he tried to fly to Syria will walk free from jail after being handed a five-year good behaviour bond.

Moudasser Taleb, who had no plane ticket and little money when arrested in mid-2017, was found guilty by a jury in April of preparing to travel to Syria for the purpose of engaging in hostile activities.

The defence had claimed Taleb had no intention of engaging in warfare and that he was mentally ill at the time.

Taleb was 22 when caught at the airport in June 2017. He was later found to have videos on his phone of beheadings, people with Isis flags and battlefields.

NSW supreme court Justice Peter Hamill on Friday said the two years Taleb had already spent in custody were adequate. The judge found him to be of good character despite his crime.

“I accept his mental illness had a significant impact on his moral culpability,” Justice Hamill said, referring to a diagnosis of schizophrenia after Taleb’s arrest.

Justice Hamill said he was in no doubt the decision to place Taleb on a good behaviour bond would be criticised by public commentators “who think no sentence is ever long enough”.

But he said all the facts before him “cry out” for a sentence that would allow “the young, mentally ill and vulnerable offender” the chance of rehabilitation.

Taleb’s impairment may have made him more susceptible to extremism and the offender was “an inappropriate vehicle” for a sentence of general deterrence, the judge said.

The lengthy bond includes stringent conditions. For the first two years Taleb must not use messaging app Telegram, access any material controlled by Isis or any other group espousing radical Islam and continue treatment for his mental illness.

The judge stressed repeatedly the young man knew what he was doing was illegal but added he wouldn’t have headed to the airport without the “quite appropriate” intervention and encouragement of an undercover police officer.

Taleb’s interest in Islam became intense in 2014 after an episode in hospital. He was already interested in joining Isis in the Middle East before the sophisticated undercover sting began.

At the advice of the operative, Taleb made preparations to go to Syria and arrived at the airport with a bag containing military clothing, a sleeping bag, tactical gloves, a solar charger and other gear.

Justice Hamill noted that when Taleb asked what he should do if turned away from the airport, the operative suggested he commit an act of domestic terrorism.

Taleb replied: “No, I’ll just look after my mum.” She suffered from multiple sclerosis and the young man looked after her full-time.

Taleb initially sat with his arms crossed during Friday’s sentencing but smiled at his lawyer when he later realised he was to be freed.

“Good luck, Mr Taleb,” Justice Hamill said as he left the courtroom.