Two prisoners have launched a high court action, claiming they have been kept in conditions so bad that their human rights have been violated.
William Beattie and Paul Hazell have both served time at Norwich prison in Norfolk, where the wing containing their cells was recently described in official inspections as "wholly unfit" and "appalling".
If their application succeeds, it could lead to scores of other prisoners bringing similar cases and claiming damages.
The Victorian Gurney wing at Norwich, also known as A wing, had been emptied of inmates ready to be demolished but it had to be reopened to accommodate prisoners because of the overcrowding crisis.
In May, the chief inspector of prisons, Anne Owers, condemned conditions on the wing as "appalling". The head of the Prison Service accepted the criticism and said the "condemned" wing would be refurbished when the overcrowding problem was solved.
A member of the Independent Monitoring Board was quoted as stating that "animals should not be allowed inside A wing" and that the smell of sewage pervaded the building.
Nicholas Blake QC, a deputy high court judge, today called for an environmental health inspector to be appointed to inspect the prison. He said the application by Beattie and Hazell for permission to seek judicial review would be adjourned pending that appointment.
Lawyers for Beattie and Hazell said the pair were detained in "very unsatisfactory" conditions.
The prisoners said water, including foul water, ran down the wall of the cells and on the floors, pigeons had fouled the floor of A Wing, it was infested by rodents, and inmates had to put up with limited dirty showers and no heating.
The high court will have to decide whether these conditions were so bad that it amounted to "inhuman and degrading treatment" in violation of the European Convention on Human Rights.
Steven Kovats, appearing for the government, queried whether an expert appointed on behalf of the prisoners could carry out a truly independent inspection. He warned that, if one was allowed in, the floodgates could be opened.
But deputy judge Blake said the case was exceptional because the chief inspector of prisons herself had commented on conditions on the wing.
Adjourning the case, the judge directed that Norwich's environmental health department be invited to consider appointing an inspector. If there was no satisfactory response, said the judge, further time should be allowed so that consideration could be given to both sides jointly appointing a candidate they both found acceptable.