The Archbishop of Canterbury has criticised the way immigrants and their families are treated when in detention.
Dr Williams spoke out after a visit to a reception centre
Dr Rowan Williams raised concerns after visiting a centre at Oakington, near Cambridge, where immigrants are kept while their asylum cases are heard.
He criticised visiting arrangements and the way families were separated.
He made a pastoral visit to the centre before speaking on "faith and society" at Cambridge University as part of its 800-year anniversary celebration.
"I think the detention system is full of problems but I am talking about the system, not about people working in it.
"I spent a lot of time in the detention centre at Oakington."
Dr Williams also spoke about the row over his remarks concerning sharia law.
He said that some of the ways in which Islamic sharia law was practised were "appalling" and the way the system was applied to women in countries such as Saudi Arabia was "grim".
"What I was trying to say the other day is that sharia law is a very, very wide-ranging scheme of legal understanding within historic Islam.
"In some of the ways it has been codified and practised across the world, it has been appalling and applied to women in places like Saudi Arabia, it is grim."
But judging sharia law on that basis would be like judging Christianity on a couple of chapters of the Old Testament, he added.
"My doomed enterprise was to try and introduce that bit of perspective. Let that be a warning to you all."
At the start of the lecture, a lone heckler accused the Archbishop of lacking common sense.
Dr Williams responded to the criticism by saying his earlier comments on sharia law had met with "scant success".