WASHINGTON — The Obama administration is planning to issue a sweeping directive telling every public school district in the country to allow transgender students to use the bathrooms that match their gender identity.

A letter to school districts will go out Friday, adding to a highly charged debate over transgender rights in the middle of the administration’s legal fight with North Carolina over the issue. The declaration — signed by Justice and Education department officials — will describe what schools should do to ensure that none of their students is discriminated against.

It does not have the force of law, but it contains an implicit threat: Schools that do not abide by the Obama administration’s interpretation of the law could face lawsuits or a loss of federal aid.

The move is certain to draw fresh criticism, particularly from Republicans, that the federal government is wading into local matters and imposing its own values on communities across the country that may not agree. It represents the latest example of the Obama administration using a combination of policies, lawsuits and public statements to change the civil rights landscape for gays, lesbians, bisexual and transgender people.

After supporting the rights of gay people to marry, allowing them to serve openly in the military and prohibiting federal contractors from discriminating against them, the administration is wading into the battle over bathrooms and siding with transgender people.

“No student should ever have to go through the experience of feeling unwelcome at school or on a college campus,” John B. King Jr., the secretary of the Department of Education, said in a statement. “We must ensure that our young people know that whoever they are or wherever they come from, they have the opportunity to get a great education in an environment free from discrimination, harassment and violence.”

Courts have not settled the question of whether the nation’s sex discrimination laws apply in matters of gender identity. But administration officials, emboldened by a federal appeals court ruling in Virginia last month, think they have the upper hand. This week, the Justice Department and North Carolina sued each other over a state law that restricts access to bathrooms, locker rooms and changing rooms. The letter to school districts had been in the works for months, Justice Department officials said.

“A school may not require transgender students to use facilities inconsistent with their gender identity or to use individual-user facilities when other students are not required to do so,” according to the letter, a copy of which was provided to The New York Times.

A school’s obligation under federal law “to ensure nondiscrimination on the basis of sex requires schools to provide transgender students equal access to educational programs and activities even in circumstances in which other students, parents, or community members raise objections or concerns,” the letter states. “As is consistently recognized in civil rights cases, the desire to accommodate others’ discomfort cannot justify a policy that singles out and disadvantages a particular class of students.”

As soon as a child’s parent or legal guardian asserts a gender identity for the student that “differs from previous representations or records,” the letter says, the child is to be treated accordingly — without any requirement for a medical diagnosis or birth certificate to be produced. It says that schools may — but are not required to — provide other restroom and locker room options to students who seek “additional privacy” for whatever reason.

Attached to the letter, the Obama administration will include a 25-page document describing “emerging practices” that are in place in many schools around the country. Those included installing privacy curtains or allowing students to change in bathroom stalls.

In a blog post accompanying the letter, senior officials at the Justice and Education Departments said they issued it in response to a growing chorus of inquiries from educators, parents and students across the country, including from the National Association of Secondary School Principals, to clarify their obligations and “best practices” for the treatment of transgender students.

“Schools want to do right by all of their students and have looked to us to provide clarity on steps they can take to ensure that every student is comfortable at their school, is in an environment free of discrimination, and has an opportunity to thrive,” wrote Catherine E. Lhamon, the assistant secretary of education for civil rights, and Vanita Gupta, the head of the Justice Department’s Civil Rights Division.

Thomas Aberli, a high school principal in Louisville, Ky., said the new guidance would help administrators across the country who are trying to determine the best way to establish safe and inclusive schools. He said his school had little to work with when it drafted a policy that was put in place last year.

“What you don’t do is go and tell a kid, ‘You know, there is something so freakishly different about you that you make other people uncomfortable, so we’re going to make you do something different’,” said Mr. Aberli, who estimated that his school of 1,350 students had about six transgender children. “There’s been no incident since its implementation. It’s really just a nonissue in our school.”

The White House has called North Carolina’s law “meanspirited” and said this week that federal agencies were continuing a review of their policies on the treatment of transgender people while the administration waged its legal battle with the state.

President Obama condemned the law last month, saying it was partly the result of politics and “emotions” that people had on the issue.

“When it comes to respecting the equal rights of all people, regardless of sexual orientation, whether they’re transgender or gay or lesbian, although I respect their different viewpoints, I think it’s very important for us not to send signals that anybody is treated differently,” Mr. Obama said at a news conference in London.

The struggle over the rights of transgender people has reverberated on the presidential campaign trail and become a defining issue in the final year of Mr. Obama’s tenure, prompting boycotts of North Carolina by some celebrities and businesses that had planned to create jobs there. The fresh guidance to be issued Friday seemed certain to intensify that debate, and showed that Mr. Obama and his administration intend to press the issue of transgender rights aggressively as the legal challenge unfolds.

The Justice Department has for years made gay and transgender issues centerpieces of its civil rights agenda. Former Attorney General Eric H. Holder Jr. described that campaign as a continuation of the civil rights era that brought equal rights to African-Americans. And this week, Attorney General Loretta E. Lynch spoke passionately to transgender people as she cast the lawsuit against North Carolina in historic terms.

“We stand with you,” she said. “And we will do everything we can to protect you going forward. Please know that history is on your side.”

Some Republicans have defended North Carolina’s law by arguing that it would be inappropriate to allow transgender women to use the same bathroom as young girls. Before ending his presidential bid last week, Senator Ted Cruz of Texas charged that Donald J. Trump, the presumptive Republican nominee, and Hillary Clinton, the likely Democratic nominee, “both agree that grown men should be allowed to use the little girls’ restroom.”