The Obama administration has told schools to allow transgender students to use the toilets that match their chosen gender identity.
Attorney General Loretta Lynch said it would protect transgender students from discrimination and peer harassment, BBC reported.
Lynch said schools may face lawsuits or lose federal aid if they do not comply.
The federal government is fighting the state of North Carolina in court over a law requiring people to use toilets according to their gender at birth.
However, the Obama administration education and justice departments said public schools must respect transgender students' gender identity even if their education records or identity documents indicate a different sex.
"There is no room in our schools for discrimination of any kind, including discrimination against transgender students on the basis of their sex," Lynch said.
Campaigners hailed the move.
"This is a truly significant moment not only for transgender young people but for all young people, sending a message that every student deserves to be treated fairly and supported by their teachers and schools," said Chad Griffin from Human Rights Campaign, a gay, lesbian and transgender rights organisation.
A new gender identity comes into force as soon as a parent or guardian notifies the school that their child's identity "differs from previous representations or records" and must be respected even if it makes others uncomfortable, the directive said.
Lynch said North Carolina's new state law had echoes of policies of racial segregation and efforts to deny gay couples the right to marry.
The federal government and the state are suing each other over the law, which the federal authorities said violates the Civil Rights Act.
However, many businesses and entertainers have criticised the measures as discriminatory.
Musicians have cancelled concerts in the states and several companies have pledged to curtail their business in North Carolina.
Last month a US appeals courts ruled that a Virginia school policy that barred a transgender pupil from using the boys' toilet was discriminatory.