It is hoped the move will improve access to education in a country where many cannot afford sanitary products like pads and tampons.
The high cost has led to an estimated one million girls missing six weeks of school every year, according to the ZanaAfrica Foundation.
But now the onus has been put on the Kenyan government to provide free sanitary towels to every schoolgirl.
The amendment to the education act, signed into law by President Uhurru Kenyatta this week, states "free, sufficient and quality sanitary towels" must be provided to every girl registered at school, as well as providing "a safe and environmental sound mechanism for disposal".
It comes more than a decade after Kenya scrapped taxes on sanitary products in an effort to make them more affordable.
Despite this, some 65% of women and girls still find them to expensive, according to figures cited in a 2016 report by non-profit consulting firm FSG.
As a result, charities like the ZanaAfrica Foundation have been providing sanitary pads for girls around the country.
However, the high price of sanitary products and the impact on girls' education is not just a problem in Kenya.
According to a 2014 campaign, girls are also missing school in countries like India, Nepal, Afghanistan and Sierra Leone for the same reason.
The issue has not just caused issues in developing countries.
Freedom4Girls - which usually provides sanitary pads to girls in Kenya - was asked to step in by a school in Leeds in northern England which was concerned about girls missing school.
One teenager told BBC Radio Leeds that she "wrapped a sock around my underwear" just to get through the school day.