Education Secretary John Swinney has bowed to legal pressure from charities and Scotland's Children's Commissioner to change the rules governing the restraint and seclusion of young people.

The Equality and Human Rights Commission and the Children and Young People's Commissioner had taken the Scottish Government to court over concerns that existing guidance for schools and other settings were flawed.

Current polices, they say are "inconsistent at best and totally inadequate at their worst" and leave some of Scotland's most vulnerable pupils at risk of human rights violations.

Facing a judicial review brought the rights bodies, Mr Swinney said he would bring in new guidance, adding: "The unlawful use of physical intervention and seclusion is completely unacceptable, and I want to do everything I can to prevent it from happening."

Restraint is defined as holding a young person to restrict their movement, while seclusion is confining a child - for example by shutting them alone in a room and preventing them from leaving.

Last year, the Children and Young People’s Commissioner’s “No Safe Place” investigation said use of restraint and seclusion on pupils across Scotland was largely unmonitored, with glaring inconsistencies across local authorities.

Its report called on the Scottish Government to produce effective and human rights compliant national guidance to direct local authorities, schools and staff in the lawful use of restraint and seclusion. Both the EHRC and the Commissioner warned the Government if it did not do so it would be in breach of its duties under international children's and human rights laws.

Although the Government did agree to refresh its existing two-page guidance, EHRC Scotland was not satisfied and since August has been supporting a Judicial Review to challenge ministers over the issue.

Now it is to drop the case, after Mr Swinney agreed to a four-point plan. The Government has agreed to produce new guidance on restraint and seclusion. Young people and their families will be involved in drafting and reviewing this and measures will be put in place to make sure all incidents are monitored and recorded, and all incidents will be recorded and monitored in a standard way across the country.

READ MORE: Charity calls for an end to 'collective shame' of restraint and isolation of learning disabled pupils 

At present this new national guidance will be advisory, but Mr Swinney has agreed pass new law to enforce it if that approach is not effective.

Lynn Welsh, Head of Legal, at the Equality and Human Rights Commission Scotland said it was vital such practices were underpinned by clear guidance to ensure school remained a place of sanctuary and safety for children.

“Across Scotland, guidance and policies on the use of restraint and seclusion in schools have been inconsistent at best and totally inadequate at their worst," she said. "We are pleased to have worked closely with the Children’s Commissioner to use our unique legal powers to achieve this change.

“No child should experience inhumane or degrading treatment at school or later in life. We welcome the Deputy First Minister’s commitment to ensure that national guidance governing restraint and seclusion is produced that is rooted in the values of human rights and co-produced by children and their families.

"We hope this guidance will protect children from disproportionate use of restraint and the negative impacts which this can have on children and young people.”

Nick Hobbs, Head of Advice and Investigation with the Children and Young People’s Commissioner said: “The use of restraint and seclusion is a human rights issue. Our investigation revealed that a lack of national guidance was leaving children in school at risk of human rights violations.

“We are pleased that the Deputy First Minister has committed to implement our recommendation to produce human rights-based national guidance on restraint and seclusion and that children and families will be involved in the drafting and review of this guidance," Mr Hobbs said. " It is particularly important that the Government will consider putting the guidance on a statutory footing if the evidence shows it is necessary."

READ MORE: Demand for new rules over restraint of children with special needs 

He said better guidelines would help teachers and others working in schools. "Clear and robust guidance will support staff and ensure that fewer children will be subjected to physical intervention in school.”

The Judicial Review was brought in the name of a parent, Ms S. She said the introduction of national guidance would be a relief to families and that restraint of her own son L had affected him emotionally, socially and academically.

“The impact of my son being restrained has been a source of great distress to him and to our family," she said. "When you entrust your child to school, there is an expectation that they will be kept safe from harm but instead, my son returned home from school scared and injured.

“However, now that he has moved to a new school ... he is settled, his confidence is blooming and he is happy. Making small changes to better consider children’s needs can make a significant and positive difference."

Education Secretary John Swinney said: “The unlawful use of physical intervention and seclusion is completely unacceptable, and I want to do everything I can to prevent it from happening. That is why I have agreed to introduce new national human rights-based guidance to ensure that for the rare occasions where it is used, it is used lawfully and ensures that children’s rights are protected.

“We will work with key partners, as well as children, young people and their families to develop the new guidance, with a review taking place a year after its introduction to test its effectiveness. I am confident that by taking forward these actions, we will be able to affect the necessary change.”