Ministers want to give pupils more of a say on closures
Plans to safeguard the future of Scotland's rural schools have been announced by ministers.
The proposed legislation would toughen the consultation procedures which councils must follow when proposing any major education changes.
The Scottish Government said the move would protect small, fragile local economies and communities.
The SNP manifesto had pledged to bring in a legislative presumption against the closure of rural schools.
Rural school closures have caused public concern across the UK, although councils argue that keeping schools with low pupil numbers open is difficult to justify.
Since 1998, there has been an average of eight rural schools closed per year in Scotland.
Scottish Education Secretary Fiona Hyslop said the Schools (Consultation) Bill would play a vital role in bolstering opportunities and services in rural communities and would make the process more open.
Ms Hyslop launched the bill, to amend current legislation from 1981, at a 10-pupil primary school in Dalwhinnie, in the Highlands.
"The majority of the children who attend here are the children of local gamekeepers whose work is essential in sustaining and fuelling the local economy," said the education secretary.
"By focusing on rural schools, we are also helping to safeguard a way of life."
The legislation, if passed by parliament, would require local authorities to publish and advertise detailed proposals on any major changes to education provision, and hold a consultation for a minimum of six weeks of term time - although these would not need to run consecutively.
Education inspectors would also have to give their views on changes, while pupils and teachers would get more of a say.
A report on the proposals would then have to be released, with a block on councils being able to make their final decision until at least three weeks after its publication.
Ministers also want to put the decision-making process over school closures firmly in the hands of local authorities.
The bill would replace the need for certain council decisions to be referred to the government, with a ministerial power to call them in where local authorities fail to comply with the legislation.
A total of 41% of of primary and 23% of secondary schools in Scotland are classed as rural.
Rural school closures have caused an outcry from parents and the public in Wales.
However, the assembly government has said there are more than 80,000 empty places, maintained at a cost of £30m a year.