New York City Mayor Bill de Blasio signed legislation Wednesday that mandates access to free feminine hygiene products in public schools, homeless shelters, jails and juvenile detention centers.

Schools with sixth- through 12th-graders will get dispensers for tampons and pads installed in girls’ bathrooms this fall, officials said.

Jails must now by law supply female prisoners with the products upon request — a practice that inmate advocates say has not always been followed.

At the bill-signing ceremony, de Blasio was introduced by Mayelin Sanchez, an 11th grader who recounted a menstruation emergency during school hours. Instead of accessing a free tampon, she had to ask multiple employees for help.

“Many times, I have felt uncomfortable and embarrassed, and I shouldn’t be, because this is a natural process in the lives of young ladies,” she said.

The legislation — a package of three bills — passed unanimously last month.

De Blasio signed the bills Wednesday afternoon at a Bronx high school in the Morrisania neighborhood.

The cost to schools is expected to be about $7 million to launch, and $5 million annually, with no new costs in the jails and other costs to be determined, according to de Blasio spokeswoman Rosemary Boeglin.