State premiere Markus Söder of Chancellor Angela Merkel's CSU sister party made the announcement on Monday, following consultations with parents', teachers' and pupils' representatives in Munich.
Only primary school pupils were exempted from the compulsory mask rule. In Bavaria, classes will resume on Tuesday, September 8th.
The compulsory masks at the start of the school year are part of the southern state's hygiene strategy, which is intended to maintain regular operations at the schools even amid the pandemic.
To minimise the risk of infection, pupils will also be required to wear a mask in buildings and wherever a minimum distance of 1.5 metres cannot be maintained.
(article continues below)
See also on The Local:
If a region of Bavaria still has a high number of cases after the nine days, the obligation to wear masks in class can also be extended, said Söder.
The aim is to maintain regular lessons in the best possible way even in the crisis. “We want to have school again in Bavaria”, he said.
Bavaria is following a similar path to North Rhine-Westphalia where pupils returned to school two weeks ago.
Face masks were made compulsory in North Rhine-Westphalia's secondary school classes for 14 days following the school holidays.
But because the number of cases has recently declined in Germany’s most populous state, contrary to the countrywide trend, the face mask rule ended on Monday.
Throughout Bavaria, masks are generally compulsory on public transport and in all places where the minimum distance of 1.5 metres cannot be maintained.
Those caught ignoring the face mask rules are punished with a €250 fine, which could rise to €500 if they are caught a second time.
In addition to masks, Bavaria also relies on extensive testing to prevent infection.