The detention of children at Dungavel has beena long-standing issue
A £150,000 pilot project aimed at ending the detention of children at Dungavel is to be launched.
Failed asylum seekers awaiting deportation will be housed in former council flats in Glasgow before they return to their own countries.
The scheme is designed to end youngsters' incarceration at the Lanarkshire centre.
The pilot follows talks between Scottish Secretary Jim Murphy and the UK Borders and Immigration Agency.
Families living in the flats will have access to basic amenities including a washing machine, fridge and furniture until they are repatriated.
Mr Murphy told BBC Scotland: "The truth is no politician of any party likes seeing families put behind a barbed wire.
"I want to see if we can do something sensible, but also sensitive, that looks after the children."
The Scottish secretary said families would be vetted before being placed in the flats in order to assess the risk of them absconding.
He added: "This is a trial based on concerns raised, in particular by the churches in Scotland. We are going to work together to see if there is a better way of doing this."
The pilot project is due to begin at the start of next year.
Dungavel has been a constant target of criticism from politicians, pro-asylum activists and church leaders since it opened in 2001.
Among those who have campaigned against the detention of children at Dungavel is the Scottish Refugee Council.
Kathleen Marshall said children should not be detained in Dungavel
Spokeswoman Aideen McLaughlin said: "We have been lobbying for an alternative to detention for many years.
"We are very pleased that the new secretary of state for Scotland is supporting this but the details as to how it will actually work still have to be hammered out."
She added: "For this to be a success it has to be evaluated and assessed. If it is done properly it could become a blueprint and could be rolled out across the UK.
"But it has to be a true alternative, not just used in addition to the detention of children and young people."
Scotland's children's commissioner, Kathleen Marshall, welcomed the new pilot scheme.
She said: "This comes not a moment too soon. Detention can cause lasting damage to the health and wellbeing of children and families, that's why I have consistently pressed for alternatives measures.
"Regardless of their immigration status, children must be treated as children first and foremost.
She added: "Today's announcement brings Scotland and the UK one step closer to recognising and upholding children's rights. I look forward to closely monitoring the progress of the scheme."