A boy in care was allegedly raped and took an overdose after a health trust changed fostering arrangements against the advice of his legal guardian.
The child also scored his arms with scissors and was hospitalised following a breakdown in his new placement.
On his release he was placed into a residential home where the alleged sexual assault took place.
The judge who heard the case at the high court in Belfast described it as "distressing".
He also expressed his concern at how the guardian's recommendations were treated.
Mr Justice Treacy said: "This may be a case in which the services involved could usefully review their procedures with a view to learning lessons and improving their practice for the benefit of all young persons who are settled in working placements and whose removal carries a high risk of changing the situation for the worse."
'Overdosing on pills'
Judicial review proceedings were taken against the Southern Health and Social Care Trust in a bid to secure the boy's removal from the care home.
He has been moved to a new foster placement since the legal action was launched the points at stake have become academic.
Judge Treacy said the courts will act if a public authority puts a child where they will be exposed to the risk of serious harm or abuse.
The boy, who cannot be named, had been placed with a foster family for 10 months until June 2011.
During that period the trust sought a care order from the Family Proceedings Court and decided to move him to a new foster home.
Both the boy and his guardian wanted the original arrangements to remain in force.
Just over a month after he was moved the new placement had broken down, resulting in incidents of self-harm and overdosing on pills.
He was treated in hospital and then placed in the residential care home in July 2011.
Less than two months later he disclosed that he had been the victim of an alleged rape and other sexual offences within the home.
A police investigation into the claims was ongoing when judicial review proceedings were launched.
Despite the allegations, the trust did not immediately move the boy out of the home, with a social worker stating that no emergency placement could be found.
By January 2012 the boy had been returned to foster care.
His guardian went to court to challenge the trust's decision to maintain him in the home, claiming it breached his human rights and child welfare laws.
His challenge was ultimately dismissed as being academic due to developments in fostering arrangements.
But Mr Justice Treacy said that the boy wanted it to proceed in the hope that a resolution would protect others from suffering as he had.
The judge also praised the boy's guardian for looking after the child's welfare and doing his utmost to secure the placement with the original foster family.
"I am concerned to see one statutory agency intervening decisively in a young person's life against advice from another statutory agency and without providing clear and compelling reasons for their intervention," he said.
"It appears to me that the course of action undertaken in this case is unlikely to represent best practice in cases of this kind."