The court in the northwestern city of Igoumenitsa said the 15 adults—from Afghanistan, Iraq, Syria, Egypt and Morocco—had been held for up to six weeks in "wretched and highly dangerous" conditions.
The decision to acquit the migrants of escaping police detention is a strong indictment of Greece's treatment of detained illegal immigrants, which has been repeatedly criticized by international human rights groups.
A spokeswoman for the United Nations refugee agency in Athens said it was a very significant first for a Greek court to acknowledge that people held in such conditions had no option but to try to escape.
The country, grappling with revived anti-immigrant sentiment amid the worst financial crisis since the end of World War II, is the main entry point to the EU for thousands of undocumented migrants from Asia and Africa and has started a drive to round up and expel them.
More than 30 inmates were crammed into an 18-square-yard (15-square-meter) cell with no running water or bedding and just one chemical toilet, according to the ruling, a copy of which was obtained by The Associated Press on Monday. It said the Igoumenitsa lockup was never cleaned and the detainees
The men had been held in the port city pending deportation for allegedly illegally entering the country, and they escaped on Oct. 1 by pushing past police guards who had entered the cell to clear garbage.
Judge Athanassios Terzoudis argued in his October ruling that both the duration and the conditions of their detention were in breach of the European Convention on Human Rights.
"Therefore, the court judges that (the detainees) escaped to avoid a severe and otherwise inevitable threat which—through no fault of their own—endangered their health, and specifically to avoid infectious diseases given their particularly limited access to medical attention care, medicine and hospital treatment," the ruling said.
The judge also ordered the Greek government to cover the court costs.
The United Nations refugee agency, UNHCR, said it had sent a report on substandard conditions at the Igoumenitsa lockup to Greek authorities after a visit in August. "It's one of the worst detention centers we've visited," said UNHCR protection officer Kalliopi Stefanaki. "Unfortunately, overcrowding, lack of fresh air and hygiene are not uncommon. We think (this ruling) should affect government policy."
Igoumenitsa has a ferry link to Italy, and is a main destination for illegal immigrants trying to stow aboard ships in a bid to reach western Europe.
For years, Greek authorities did little to stem the tide or ensure humane treatment and access to asylum proceedings for migrants. But under the double pressure of rising immigration-related crime and anti-immigrant sentiment that brought a xenophobic, quasi-neo-Nazi party to Parliament last year, the government in August started the drive to kick out illegal immigrants.
So far, more than 4,000 people have been interned in former military bases and crammed into police holding cells pending deportation, in an operation curiously code-named after Zeus Xenios, the ancient Greek god of strangers.
Under new laws, detainees can be held for up to 18 months before being served their deportation orders—which they have a couple of weeks to appeal.
Police said the 15 immigrants in the court ruling still face deportation, but have been transferred to a different holding location.
An officer said the initial facility had been used as a "temporary" measure since there had been no others available. The officer spoke on condition of anonymity because he was not authorized to discuss the case with the media.