The Scottish Government said it is the first government in the world to make such products available to all pupils and students.
The scheme is aimed at helping to prevent so-called period poverty among Scotland’s 395,000 school pupils and college and university students.
Communities Secretary Aileen Campbell said: “In a country as rich as Scotland it’s unacceptable that anyone should struggle to buy basic sanitary products.
“I am proud that Scotland is taking this world-leading action to fight period poverty and I welcome the support of local authorities, colleges and universities in implementing this initiative.
“Our £5.2 million investment will mean these essential products will be available to those who need them in a sensitive and dignified way, which will make it easier for students to fully focus on their studies.”
The Government has worked with council body Cosla, Colleges Scotland, Universities Scotland and the Scottish Funding Council to roll out the scheme to coincide with the start of the new term.
Meanwhile, additional funding has been given to FareShare to extend a scheme providing free sanitary products to women from low-income households.
The organisation has received more than £500,000 to reach an estimated 18,800 more people following a successful pilot in Aberdeen.