The Scottish Government is to agree compensation with the management of two secure accommodation centres which are run by the Catholic Church, after deciding to close 12 beds intended for young offenders and children at risk.

The homes, St Mary's, Kenmure, near Glasgow, and St Philip's, in Airdrie, are still to shed more than 50 jobs as a result of the declining market for secure care.

The government acknowledged the likely job losses which it said were "extremely regrettable", but added in a statement: "It is the only way to ensure the sustainability and cost-effectiveness of the sector as a whole."

The statement says the facilities will be given "short term" compensation to meet the cost of mothballing the 12 places, but a Government spokesman said talks were ongoing about the sums involved.

The homes accommodate under 16s who are sent to be detained as a result of offending or because they are deemed at risk, usually by a children's panel or a sheriff.

The so-called "secure estate" is set at a size determined by the Government. There are currently 124 secure places in Scotland, but although the previous government invested millions in expanding the estate, most have been running under-capacity for some time.

A recent report found there was a need to cut places in a planned way, to avoid homes going out of business. After a series of changes, the overall number of places will shrink to 106.

Six places at the Airdrie home and six at St Mary's in Bishopbriggs are to be mothballed, with their boards of management compensated by the Government for the loss of revenue. Dundee City Council's Rossie Elms unit is already losing six places, shrinking from 24 beds to 18. Scotland's councils have agreed the changes.

The Cora Foundation, a non profit-making company owned by the Catholic Bishops' Conference of Scotland represents the boards of the two secure facilities. A Cora spokesman said it would be necessary to cut an estimated 12 jobs at St Philip's and 40 at St Mary's. Another 14 jobs will go at another Cora facility, Springboig St John's, in Glasgow, although it is not directly affected by the reduction in secure places.

Monsignor Peter Smith, chairman of the board of Cora, said the plans offered "a welcome way forward which preserves the expertise which has been built up over many years by our schools and also seeks creative solutions to what may be a temporary problem of over-capacity".

The Government announced the measures in response to February's report from the Securing Our Future initiative (SOFI), and said it and Cosla had agreed to adopt the report's findings in full.

The SOFI report is part of a wider initiative examining Scotland's residential child care provision, which is led by the Scottish Institute of Residential Childcare (SIRCC).

Romy Langeland, Chair of SIRCC and the SOFI working group, said: "We warmly welcome the minister's support for the work that has been done over recent months.

"We recognise that we will not be able to achieve the changes that are required without the full collaboration of those involved - the Scottish Government, local authorities, secure care providers and others in the voluntary sector. Only together can we work towards directly addressing the sources of young people's distress and behaviour."

The main recommendations in the SOFI report were for local authorities and other agencies to take measures to ensure that secure care for children is only used when absolutely necessary. As well as the bed closures, use of secure care and alternative approaches to working with troubled under-16s are to be carefully monitored to inform future decision making.

Minister for Community Safety, Fergus Ewing, said: "We recognise the important function secure care has in protecting young people and the community. However, our ultimate ambition must be to have no child in Scotland in secure care. Every child in Scotland should get the best start in life and the right help when they need it in order to prevent risks turning into poor outcomes.

"Where it is possible to meet the needs of high-risk young people safely and cost-effectively in their communities, then these opportunities should be maximised.

"However, for the very small number of children whose needs can only be met in secure care, then we have to provide a high quality and nurturing environment that addresses their needs. It is therefore important that we do not lose secure care capacity in an unplanned way."

Councillor Isabel Hutton, Cosla spokesperson for children and young people, said: "In the end our success will be measured by how effectively we manage to reduce the need for secure provision. This report and the recommendations included in it are a helpful step in the right direction."

A spokesman for the public sector union Unison said its members were concerned about the job losses and the reduction in secure care beds.

www.scotland.gov.uk/responsetothesecuringourfutureinitiativereport