TORONTO -- No proof exists that solitary confinement will necessarily hurt an inmate's mental health, while international law sets no definitive limits on the length of segregation, a federal government lawyer argued Wednesday.

On the second day of a four-day court hearing, Justice Department lawyer Peter Southey said isolating inmates who are either at risk of harm to themselves or who threaten the safety of others is a last-resort practice circumscribed by constitutional laws and carefully crafted policies.

"Penitentiaries are difficult and dangerous places," Southey told Superior Court. "The law and policy very carefully balance the competing issues."

Administrative segregation entails spending up to 23 hours a day without any meaningful human contact, a practice critics say can cause serious psychological harm to inmates.

The Canadian Civil Liberties Association and the Canadian Association of Elizabeth Fry Societies want Justice Frank Marrocco to strike down a law they argue amounts to cruel and unusual punishment because they say it essentially allows for indefinite solitary confinement.

Among other things, they want a 15-day cap on the length of segregation and a ban on putting mentally ill inmates or those aged 18 to 21 in solitary.

However, Southey argued prison authorities are duty-bound to keep everyone safe. To that end, Parliament has recognized cases can arise where administrative segregation is required but under strict conditions. Those include a lack of reasonable alternatives, and placements must be as short as possible.

Contrary to the assertions of the rights groups, Southey argued, the current system contains numerous safeguards. For example, an inmate's health-care needs, both mental and physical, must be taken into account and necessary care provided. He also said isolation placements must be institutionally reviewed and inmates can turn to the courts.

A new policy already precludes placing those with serious mental-health issues in segregation, Southey said, but banning the practice for the mentally ill or younger prisoners will not resolve the "extraordinary" threats prisons face.

Earlier in the day, a lawyer for the liberties association argued wardens have the authority to place inmates in potentially harmful solitary without any meaningful review.

"Current safeguards do not provide a level of procedural fairness that is commensurate with the extreme deprivation of liberty," Michael Rosenberg said. "A warden is making a decision to segregate…and then a warden is being asked to review his or her own decision."

The way to deal with the situation is to force correctional authorities to find alternatives to the "vicious cycle" of inmate isolation by striking down the current "structurally deficient" law, Rosenberg said.

Marrocco frequently interrupted Rosenberg, suggesting Correctional Service Canada is between a rock and hard place in dealing with inmates who need protecting from fellow prisoners or who are themselves prone to violence.

"You don't design a system around those extreme situations," Rosenberg said.

Prisoners can also be isolated for disciplinary reasons, but the procedures are different and have more safeguards than administrative segregation, court heard.

Correctional services data indicate about 4,500 inmates are placed in administrative segregation in any given year -- some more than once -- for an average of 24 days. Southey said the frequency and length have been declining in recent years.

Southey dismissed as anecdotal and irrelevant affidavits filed with the court by three inmates -- one a murderous gang member -- in which they discuss the harm they suffered and problems they encountered in segregation. What the accounts do show, he said, is just how difficult managing a prison is.

The hearing continues Thursday.