The announcement comes amid heated debate over transgender rights in schools and public life, which includes a legal standoff between the administration and North Carolina over its controversial House Bill 2. The guidance goes beyond the bathroom issue, touching upon privacy rights, education records and sex-segregated athletics, all but guaranteeing transgender students the right to identify in school as they choose.

"There is no room in our schools for discrimination of any kind, including discrimination against transgender students on the basis of their sex," Attorney General Loretta Lynch said. "This guidance gives administrators, teachers and parents the tools they need to protect transgender students from peer harassment and to identify and address unjust school policies."

The letter does not carry the force of law but the message was clear: Fall in line or face loss of federal funding.

North Carolina Gov. Pat McCrory slammed the guidance and called on Congress to address the issue.

"Most Americans, including this governor, believe that government is searching for a solution to a problem that has yet to be defined. Now, both the federal courts and the U.S. Congress must intercede to stop this massive executive branch overreach, which clearly oversteps constitutional authority," McCrory said in a statement.

Sen. Lamar Alexander, the chairman of the Senate Health, Education, Labor and Pensions Committee, reiterated in a statement that the guidance was not federal.

"This is the kind of issue that parents, schools boards, communities, students and teachers should be allowed to work out in a practical way with a maximum amount of respect for the individual rights of all students. Insofar as the federal government goes, it's up to Congress to write the law, not the executive departments," the Tennessee Republican said.

Justice and Education Department officials have repeatedly made clear that under their interpretation of Title IX, the federal anti-discrimination law in education, schools receiving federal funds may not discriminate based on a student's sex, including a student's transgender status.

"The guidance makes clear that both federal agencies treat a student's gender identity as the student's sex for purposes of enforcing Title IX," the administration said Thursday.

"The families in America will not accept it," Patrick said at a news conference.

LGBT groups praised the announcement, calling it a validation of transgender rights and a repudiation of so-called "bathroom bills" that ban people from using public bathrooms that do not correspond with their biological sex.

"These groundbreaking guidelines not only underscore the Obama administration's position that discriminating against transgender students is flat-out against the law, but they provide public school districts with needed and specific guidance guaranteeing that transgender students should be using facilities consistent with their gender identity," said Human Rights Campaign President Chad Griffin.

"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."

The letter emphasizes the departments' shared position that schools must treat transgender students the way they want to be treated based on their gender identity, regardless of how others may feel about it.

Schools should let transgender students use bathrooms, locker rooms and other sex-segregated facilities consistent with their gender identity, according to the guidance. Staff should address transgender students by their preferred names and pronouns. Schools cannot require students to have a medical diagnosis, undergo any medical treatment, or produce a birth certificate before treating them consistent with their gender identity, the guidance 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 to ensure that all students, including transgender students, can attend school in an environment free from discrimination based on sex," the letter says.

The guidance takes the same approach to the bathroom issue: A school may provide gender-separated facilities but it must allow transgender students access to such facilities consistent with their gender identity. If a school opts for individual stalls it must make them available to all students.

U.S. Secretary of Education John B. King Jr. said the letter comes in response to request from schools and parents seeking guidance.

"This guidance further clarifies what we've said repeatedly -- that gender identity is protected under Title IX," he said. "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."