A Sydney teenager who allegedly planned a mass killing must remain behind bars as he waits to face terrorism charges.

The red-eyed 17-year-old, whose lawyer said had been diagnosed with Asperger’s syndrome and suffered from depression and anxiety, covered his face in his hands before wiping away tears as he was led from the Parramatta children’s court dock late on Thursday by juvenile justice officers.

During an extraordinary bail hearing, the court heard allegations the youth had spent up to three months planning a mass killing and had even obtained a knife he planned to use – and which is yet to be found.

Police have alleged the teenager, who cannot be identified for legal reasons, created an attack map and attempted to erase hard drives in the days before his arrest.

Magistrate Jeffrey Hogg said the allegations levelled against the teenager involved “a very direct statement of intent to commit acts of violence” including “mass killings with a knife”.

“He had found a knife with which to carry out those killings but had not disclosed its location [to police],” Hogg said before refusing bail.

The magistrate added that the teenager had also written on his Facebook page “that the victims in the Orlando massacre were people that ‘all deserved it, every each one of them. Thank you and God bless for the shootings’, with a love-heart emoticon”.

Although the boy’s family had gone so far as to propose dead-locking him inside the family home near Camden, south-west of Sydney, Hogg found that the teenager had failed to demonstrate that exceptional circumstances existed in his case that would justify his release.

Under commonwealth law, a person charged with terrorism offences must clear that first crucial hurdle before a court can consider granting bail.

“In the absence of any clear medical evidence that would suggest it one way or another, the burden is not discharged,” Hogg said.

The decision means the youth is likely to remain behind bars for months.

The boy’s mother left the courtroom in tears in the moments after she learned her son would not be allowed home.

His father and grandmother, who were also in court, appeared shaken.

Earlier on Thursday, the court heard the youth’s threats on social media specified a time and place for his planned attack.

Prosecutors will allege he later admitted to police that the planned violence was aimed at “raising awareness” of mental health and suicide prevention.

But defence lawyer Aaron Tang questioned whether the boy’s alleged actions – even if proven – could amount to terrorism.

He said his client had no links to any terror organisations and was socially isolated, in part due to his autism-spectrum disorder and his experience of schoolyard bullying.

“The question, and I don’t want to put it flippantly, but is a child Rain Man a terrorist?” Tang said.

The case is expected to return to court on 8 August.