A 10-year-old refugee boy who has made repeated attempts to kill himself while held on Nauru has been ordered moved to Australia for acute psychological care, with a judge saying the boy would be at imminent risk of dying if left in the regional processing centre.

In the federal court this month, lawyers representing the boy – known in court documents as AYX18 – applied for an injunction to have him moved to tertiary-level psychiatric care.

The home affairs department – which controls Australia’s offshore processing regime – fought the injunction, arguing that there was sufficient healthcare on the island to treat the boy and asking the court to delay the court hearing a week.

Justice Nye Perram disagreed and ordered that the boy be immediately returned to Australia for treatment: “A delay … cannot be justified, there is a significant risk the boy would not be alive by that hearing, and I am not prepared to run that risk.”

The boy and his mother, represented by the National Justice Project, have been moved to Australia and the boy is receiving treatment.

The 10-year-old also has a long-running physical health issue that requires surgery. The court heard from the government’s own health contractor, International Health and Medical Services, that the Nauru hospital was unsafe for surgery and that patients had died during routine operations.

“Although the hospital at Nauru is said to be able to fix that problem, two of its patients died as a result of the actions of the anaesthetist on the island who was then arrested,” Perram’s judgment said. “The advice of IHMS is that the hospital is not recommended.

“I mention this to reject the minister’s submission that that at least the [physical condition] could be treated in Nauru. I also reject the minister’s submission that the mother’s refusal to permit the boy to be operated upon in Nauru might be seen as part of the problem.”

Perram said the boy’s mother’s reluctance to allow him to undergo surgery on Nauru was understandable. “It can hardly be seen as unreasonable not to expose her son to that kind of risk.”

The boy, his mother and father, fled Iran in 2013 and arrived in Australia by boat on 23 July that year, just four days after the then prime minister, Kevin Rudd, decreed that no asylum seekers arriving by boat would ever be settled in Australia.

The family were recognised as refugees – suffering from a well-founded fear of persecution in their homeland – in 2014. On Nauru the boy’s father had a bicycle accident which resulted in a serious brain injury: he was moved to Australia for medical treatment and has remained in immigration detention in Brisbane since that time.

The boy’s mental health has been of concern to his family since late 2013, when he was just six years old. Beginning in late 2013 he began to suffer night terrors and had a fortnight-long episode of suicidal ideation.

He was recommended for transfer to Australia in July 2017. This was rejected five months later in December.

Since then “the boy’s mental health has gone downhill rapidly”, Perram told the court.

In January he attempted suicide by overdosing on drugs, tried to strangle himself in hospital and grabbed a paring knife that had to be wrestled from him.

A psychiatrist, Dr Gordon, reported that the child’s mental condition was critical. “[AYX18] is deteriorating significantly with the current care provided on Nauru by IHMS and the local hospital. I strongly recommend that [AYX18] and his mother are taken to the mainland for reunification with his father and surgical and psychiatric treatment by clinicians specialising in child psychiatry.

“Should these recommendations not be followed, then I am very concerned about the developmental risks to [AYX18] in developing a more chronic severe mental health problem which will be very difficult to treat, his current and real risk of further suicide attempts and completing suicide, as well as the risk of his mother attempting or completing suicide.”

The judge ruled that Australia “held a duty of care” to the boy and his family as the entity that had placed them on the island and which ran the offshore processing centre and the regime that held them.

Perram said while he conceded the cost to move the boy and his mother to Australia and to house and treat them would be significant, the requirement to provide sufficient care outweighed any monetary cost or injury to government policy.

“Given that the applicant [the boy’s mother] is in Nauru because that is where the minister desires her to be, it is perhaps a little unreasonable to complain of a circumstance which the minister may himself be seen to be the author.”

The federal court order is at least the second concerning a critically mentally ill child held in regional processing on Nauru in recent months. In December Justice Bernard Murphy granted an urgent injunction to move a pre-teen girl off the island, ruling she was at “extreme risk” of making further suicide attempts if left there.

“There is an extreme risk this unfortunate young girl will commit suicide or otherwise self-harm, or that her mental health will further deteriorate,” Murphy said. “Being stuck on Nauru since 2013, coupled with the recent separation of her parents, appears to have taken a serious toll on the applicant’s mental health.”

The girl was transferred to Australia, where she is receiving treatment.

• In Australia, the crisis support service Lifeline is 13 11 14. In the UK, Samaritans can be contacted on 116 123. In the US, the National Suicide Prevention Lifeline is 1-800-273-8255. Other international suicide helplines can be found at befrienders.org