A plan to provide the country's first legal drug injection centre at Dublin's Merchant's Quay has been rejected by the High Court.
The planning permission granted by An Bord Pleanála was ruled invalid following a judicial review taken by the board of a primary school immediately beside the proposed facility in Dublin City Centre.
Mr Justice Garrett Simmons said the main reason for his ruling was the "inexplicable" and "startling" failure of the planning board to deal with the concerns of St Audeon's National School in its decision to grant permission.
The judge said the proposed facility would allow the possession of drugs near the facility and the school feared that this would create a "drugs marketplace".
They had produced evidence from psychiatrists on the negative effect on children witnessing such behaviour.
However, the judge noted there was no reference to the school or its pupils in the planning board's decision.
He also ruled that the board's three-year permission was "unreasonable" give that the HSE had only proposed a maximum initial trial for 18 months.
Mr Justice Simmon invited submissions on referring the case back to An Bord Pleanála and on costs.
Merchant's Quay Ireland who won the tendering process to operate the facility had appealed to An Bord Pleanála after Dublin City Council refused planning permission.
This followed a large number of objections from local residents and businesses concerning drug taking and anti-social behaviour that they believed would get worse if the facility went ahead.
However, Merchant's Quay argued that the supervised injection facility would reduce these problems.
In response to the High Court ruling, Merchant's Quay said it would consider the judgment.
It added: "We remain committed to the opening of a Medically Supervised Injection Facility as part of a health led approach to addiction. There is a clear need for this facility. These services save lives."

The principal of St Audeon's National School Eilish Meagher welcomed the court ruling and said the school had reluctantly taken the challenge to uphold their obligations to the children.
Ms Meagher called for restrictions on licences for injection centres so they would not be allowed within 300 metres of schools, similar to 'No Fry Zones' in some council areas, which prohibit fast food outlets near schools.
She also pointed out that there are restrictions on alcohol advertising in relation to schools.