WASHINGTON — Attorney General Jeff Sessions attacked American colleges and universities Tuesday for being “politically correct,” infringing on students’ free-speech rights and capitulating to the demands of loud protesters.

In a speech at Georgetown University Law Center — where dozens of students gathered to protest — Sessions cited a study that surveyed 450 colleges and universities and found that 40 percent have codes that “substantially infringe on constitutionally protected speech.”

“Freedom of thought and speech on the American campus are under attack,” Sessions said. “The American university was once the center of academic freedom — a place of robust debate. But it is transforming into an echo chamber of political correctness and homogenous thought, a shelter for fragile egos.”

Underscoring his intention to bring action to his words, Sessions said the Justice Department is filing a “statement of interest” in a campus free-speech lawsuit filed by students at Georgia Gwinnett College. Students at the public school are challenging a policy that limits students’ expressive activity to two small free-speech zones, requires students to obtain approval from campus officials and restricts their activity to a specific date and time, Justice officials said.

“We will be filing more in the weeks and months to come,” Sessions said.

Sessions’ speech comes days after President Donald Trump criticized NFL players who took a knee during the national anthem to protest shootings of unarmed African-Americans by police.

“This attorney general is coming to our campus to tell us to exercise our constitutional rights, when he and the president have repeatedly condemned those who have exercised those rights,” said Spencer McManus, a third-year Georgetown University law student from California. “We want people to understand what the First Amendment means.”

In a question-and-answer session after his speech, the attorney general defended Trump’s comments about NFL players and said he agreed with the president.

“Well, the president has free speech rights, too,” Sessions said. “He sends soldiers out every day to defend this country under the flag of the United States, under the national anthem and the unity that those symbols call on us to adhere to.”

“So, I agree that it’s a big mistake to protest in that fashion because it weakens the commitment we have to this nation that has provided us this freedom,” Sessions said.

With his speech, Sessions waded into a controversial and sometimes violent campus debate. A “Free-Speech Week” at the University of California at Berkeley was canceled Saturday by student organizers, the day before it was scheduled to begin. In February, a planned speech there by controversial writer Milo Yiannopoulos was shut down by violent protests.

At Howard University last week, former FBI Director James Comey was heckled and jeered throughout a speech by protesters who chanted “No justice, no peace” in a loud standoff that did not end until Comey finished his speech.

In March, a Middlebury College professor was hurt and hospitalized after protests outside the speech of a conservative political scientist.

Sessions singled out several other colleges and universities in his remarks, including Boise State University and Clemson University in South Carolina.

“At Boise State University in Idaho, the student code of conduct prohibits conduct ‘that a reasonable person would find offensive,’” Sessions said. “At Clemson University … the student code of conduct bans any verbal or physical act that creates an ‘offensive educational, work or living environment.’

“But who decides what is offensive and what is acceptable?” Sessions said. “The university is about the search for truth, not the imposition of truth by a government censor.”

A Clemson representative said in an email that the school welcomes “robust and vigorous discussions on our campus on all manner of topics” and that its policies on speech are consistent with the First Amendment.

A Boise State spokesman said the policy Sessions referenced isn’t about offensive speech but instead addresses disorderly conduct that could be construed “as lewd, indecent, obscene, or profane.” The school said it spent a year revising its free-speech policies in partnership with a conservative group and with the Idaho branch of the American Civil Liberties Union.

On the steps of Georgetown’s McDonough Hall, about 100 protesters held signs that proclaimed, “DEPORT HATE,” “FREE SPEECH IS NOT HATE SPEECH,” and “Sessions is afraid of questions.” The students were joined by faculty members who initially took a knee and later linked arms.

“A law school is a place for people to learn about the deepest principles that undergird our democratic republic,” said Georgetown law professor Heidi Li Feldman, one of about 40 faculty and staff members who joined the students. “You cannot invite people who so thoroughly threaten the basic premises of American law to a campus and not speak up if your mission in life is to educate people about the American legal system.”

Inside the hall where Sessions spoke, a line of attendees sitting near the back stood up as the attorney general concluded his address. The group sat back down, and had black tape over their mouths.

On Monday, some students said they got messages informing them they would not be allowed to attend the event because they were not on the invitation list drawn up the by the Georgetown Center for the Constitution, which hosted Sessions.

Georgetown law student Greyson Wallis, among those who demonstrated in the audience, said protesters were upset about emails stating that invitations to the event had been withdrawn.

“It seemed like they were rescinding those invites because they didn’t want any sort of hostile environment, and I can understand not wanting to have a violent environment, but that’s not at all what we were trying to do,” said Wallis, 24, from Bradenton, Florida. “We’re law students. We all just wanted to hear what he had to say and let him know where we differ from his opinions.”

More than 130 students who had followed official channels to register for a seat were told they could attend, Lauren Phillips, a student at the school, wrote in an email Monday. But the students were suddenly uninvited because they were not part of a group that, Phillips said, would ensure a sympathetic audience.

Randy Barnett, director of the Center for the Constitution, which offers programs “placing special emphasis on how best to remain faithful to the Constitution’s text,” did not immediately respond to a request for comment Monday.

But there were students who welcomed Sessions’ comments.

Joshua Spielman, 29, a Georgetown law student in the audience, said he felt it was important for the university to “uphold the values of allowing all speech.”

“I find that there are students who believe themselves to be in the ideological majority without understanding that there may be students who want to hear a free flow of ideas,” Spielman said. “But that doesn’t necessarily mean they agree with everything that the administration has to say. And I think it’s important as a university for us to ensure that all ideas are heard.”

Washington Post writer Susan Svrluga contributed to this report.