Society should be "ashamed" for not protecting a suicidal girl in secure custody, a senior judge has said.
The president of Family Division of the High Court said there would be "blood on our hands" if the 17-year-old did not now receive adequate supervision.
She is due to be released in 11 days, but a secure unit place has not yet been found for her - a situation Sir James Munby said was "utterly shaming".
NHS sources later indicated that three possible beds had been found.
Dr Mike Prentice, medical director for the NHS North Region, said: "A number of options have now been identified, with detailed clinical and social assessments taking place tomorrow (Friday) to ensure the right package of care can be put in place before her release date."
The girl, identified only as "X", has tried to kill herself several times.
The judgement in the case of X - who is in the formal care of Cumbria County Council - revealed she was convicted at a youth court and has been detained in custody for almost six months.
Sir James had previously noted the "enormity of the task facing the local authority" but stressed that the need for a final care plan was "overwhelming".
During the latest hearing in July, he emphasised this need further, adding: "On a large number of occasions... X has made determined attempts to commit suicide".
Staff at the unit where she is being held have said sending her back to her home town would be a "suicide mission to a catastrophic level".
The judgement said: "Staff do not think it will take more than 24 to 48 hours before they receive a phone call stating that X has made a successful attempt on her life."
An earlier ruling heard how unit staff had witnessed "a profoundly disturbing and distressing scene when X self-harmed by repeatedly banging her head and face against the wall".
Staff have said she has to be checked every 50 seconds when she is in the shower.
Earlier, Simon Rowbotham, the solicitor for the legal guardian of the teenage girl, told the BBC that X has a "determined wish" to kill herself and lives in a stripped-down room and is restrained "for hours on end".
By Mark Easton, home editor, BBC News
The problem of providing suitable services for disturbed children and young people has been flagged up to ministers before.
Two months ago, after complaints from police that cells were being used to accommodate youngsters who should have been in a mental health unit, the government introduced a law banning their use for such purposes.
Doctors are warning there is still a critical shortage of appropriate care beds.
A survey of child and adolescent mental health workers, conducted by the Royal College of Psychiatrists in 2015, found 62% had seen adolescent patients held in inappropriate settings, with 14% saying patients had attempted to kill themselves while waiting for a suitable bed.
The prime minister has promised a "revolution" in mental health care, and the number of mental health staff in the NHS in England is rising by 21,000.
But the agonies of a judge unable to help a suicidal young woman suggest the revolution still has some way to go.
When X was younger, she "was a child with poor school attendance, low-level criminality and periods of absconding", a previous judgement said.
In Sir James' judgement, delivered in private in the High Court family division sitting in Manchester, he said: "If this is the best we can do for X, and others in similar crisis, what right do we, what right do the system, our society and indeed the State itself, have to call ourselves civilised?
"The honest answer to this question should make us all feel ashamed."
He went on: "I feel shame and embarrassment; shame, as a human being, as a citizen and as an agent of the State, embarrassment as President of the Family Division, and, as such, Head of Family Justice, that I can do no more for X".
Liberal Democrat former health minister Norman Lamb told the BBC that the judgement reflected a "wholly unacceptable situation in our country".
"This is not a unique case, families are being let down routinely across our country and there is a moral imperative that we address this as a matter of real urgency," he said.
By Philippa Roxby, health reporter, BBC News
There are about 1,440 hospital beds for children and young people with mental health problems in the NHS in England.
But a recent review found that they were not evenly spread across the country - for example, some areas had no in-patient beds within a 50-mile radius.
The picture is also complicated by who those beds are for - some are in specialist units for children with eating disorders, others are in high dependency units for young people with complex needs.
And there are many more specialist beds than high dependency ones.
This means that children and their families often travel large distances to access in-patient treatment.
NHS England says it wants to change this by increasing the number of beds in badly-served parts of the country and by offering crisis help to children and young people in the community, at an earlier stage.
Mr Lamb said if investment was not made up front in the NHS, families would continue to be let down.
"The real problem is that the whole of the finances of the NHS are under such strain that the government's fine words about recruiting extra staff won't be delivered, because the money won't get through to mental health.
"Mental health always loses out whenever the money is tight and I fear that that will be the same again this time."
Earlier this week, Health Secretary Jeremy Hunt announced that thousands more mental health workers were to be recruited by the NHS in England.
The government said an extra £1bn already promised for mental health services in England would fund the scheme - part of a pot of £1.3bn committed in 2016 to transform provision.
The judge said copies of the ruling would be sent to the chief executive officer of NHS England Simon Stevens, Home Secretary Amber Rudd, Health Secretary Jeremy Hunt, Education Secretary Justine Greening and Justice Secretary David Lidington.
Labour MP Luciana Berger, who previously served as shadow minister for mental health, tweeted that it was a "devastating" judgement, while Conservative MP and former children's minister Tim Loughton said it was "worrying".
This is worrying and very significant from James Munby who is widely respected https://t.co/34Xtc8RMbT— Tim Loughton MP (@timloughton) August 3, 2017
Professor Wendy Burn, president of The Royal College of Psychiatrists, said some mental healthcare units were "desperately short" of suitable beds.
She said the college urged the government in 2015 to prioritise investment in crisis care services for children and young people.
It had also called on NHS England, clinical commissioning groups and social services to ensure emergency care pathways were in place.
"It's alarming to see that two years later, children are still not getting the support they need," Prof Burn said.