Scottish secondary school pupils will have to wear face coverings in corridors, communal areas and school buses from next Monday.
Education Secretary John Swinney said the new rules would apply to all pupils aged over 12.
He said the guidance had been updated based on new advice from the World Health Organization (WHO).
There will be no requirement to wear face coverings in classrooms where distancing measures are in place.
Mr Swinney said individual exemptions could be granted for health reasons, but the guidance would be “obligatory” for all secondary, special and grant-aided schools.
He told the BBC’s Good Morning Scotland programme: “From August 31st young people over the age of 12 in secondary schools should habitually be wearing face coverings when they are moving around schools and corridors and in communal areas where it is difficult to deliver the physical distancing.”
He said the Scottish government had acted in the light of the new WHO advice based on evidence that teenagers can infect others in the same way as adults, but had decided to go further by extending it to school transport.
“It’s part of the general measures we are taking to ensure we keep pace with the emerging advice about how to keep our schools open and to keep our schools safe,” he said.
Young people returned to Scotland’s schools earlier in August with no requirements for physical distancing between younger pupils, and no rules around face coverings.
But First Minister Nicola Sturgeon signalled on Monday that a change in the guidance was imminent.
The new rules for school buses will apply to pupils over the age of five, in line with guidelines for public transport. Staff and students can continue to wear face coverings in all settings voluntarily if they wish.
Eileen Prior, executive director of the parents’ organisation Connect, formerly known as the Scottish Parent Teacher Council, earlier said she hoped schools would be offered some flexibility over how the new guidance was implemented.
She said: “In some schools it won’t be necessary – it depends very much on the environment within a school.
“Some schools are incredibly crowded but some simply aren’t and some are well below capacity, perhaps with wide corridors and they don’t have the issue that we have in many high schools of young people just crowding because they just can’t not crowd.”
But Mr Swinney said while the new rules were not mandatory, they had the same status as other guidance on reopening of schools, such as physical distancing and hand hygiene, and should be considered “obligatory” across the secondary sector.
“There will be exemptions from this because the wearing of face coverings is not suitable for all individuals and that has to be respected,” he said.
He also stressed that an individual pupil should not be excluded from a school because they were not wearing a face covering.
The UK government has said there are “no plans” to introduce similar measures when schools return in England after the summer break.
Head teachers, however, have complained about a lack of clarity and asked whether English schools would have the flexibility to allow masks if requested as a safety measure by teachers.
Linda Bauld, professor of public health at the University of Edinburgh, said the revised guidance in Scotland was a sensible move.
She said: “The schools have done brilliantly well getting going again but I think their physical distancing in some of the communal areas is always going to be a bit of a challenge to enforce… when we’ve still got cases circulating in the community this will provide additional protection when it’s difficult to physically distance.”
She said there may be more work to do to educate young people about the correct way to put on or remove a face covering.
“Not touching the surface – taking it off around the ears. I would recommend young people might carry a little bag in their pocket, stick the face covering in there and when they’re taking it off and when they’re putting it back on, making sure they don’t touch the front of it,” she said.
“And then of course there’s the cleaning issue – these coverings need to be washed, just in warm water and soap.”
The interim chief medical officer, Dr Gregor Smith, said the education advisory group had considered carefully whether poor hygiene while using masks might spread the virus.
“In their consideration they looked at the evidence from infection from removing masks, on and off, and whether that was likely to play a significant component in terms of introducing an increased risk of transmission,” he said.
“On balance, their assessment of that evidence was that there was insufficient evidence to support that view.”
The EIS teaching union welcomed the announcement as a “sensible and appropriate step” but repeated its call for investment in more teaching staff to allow smaller class sizes.
General secretary Larry Flanagan said: “There needs to be a much sharper focus on ensuring social distancing in schools to protect pupils, staff and the wider community. Smaller class sizes to ensure appropriate physical distancing of pupils are essential.”