A 16-year-old boy held in solitary confinement for four months was a victim of procedural "failings", Liz Truss has admitted.
The Justice Secretary "regretted" prison rules at Feltham Young Offenders Institution had been breached, the High Court has heard.
But her lawyer denied the boy, who has mental health problems, was held in "inhuman and degrading" conditions.
Tom Weisselberg QC said he was isolated because of his "challenging" behaviour.
Ms Truss is contesting claims brought forward by the boy's mother, that his confinement in a cell by himself for 23-and-a-half hours a day amounted to inhuman or degrading treatment.
Mr Weisselberg said the boy, known as AB, had a "history of assaulting staff" and had used "rude, racist and threatening language" to them and other inmates at Feltham.
Mr Weisselberg admitted it was "unlawful" that the boy was unable to do activities with other young people.
AB's "removal from association" breached Article 8 of the European Convention on Human Rights - the right to a private and family life - and did not comply with prison regulations, the court heard.
He also said AB did not receive the statutory minimum of 15 hours' education per week - also in breach of prison rules.
But Mr Weisselberg said the teenager had made racist remarks to Muslim and black inmates which had inflamed tensions at Feltham.
"That racism has led him to be a target," he said, adding that AB's "challenging" behaviour required "very careful management".
"The prison has not sat on its hands," he said.
The hearing continues.