WASHINGTON—President Trump put colleges and universities on notice Thursday that they could lose federal funding if they don’t protect free speech, addressing a longstanding complaint of conservatives but sparking concerns the move could wind up squelching free expression instead.

The executive order issued Thursday afternoon requires federal agencies that give research dollars to universities to ensure the schools comply with the First Amendment, or with their own stated free-speech policies in the case of private schools. The Trump administration has long argued that schools have unfairly restricted conservative students and speakers on campus.

“Under the guise of speech codes and safe spaces and trigger warnings…universities have tried to restrict free thought” and impose liberal conformity, Mr. Trump said at the White House, flanked by students who he said had been penalized by their institutions for expressing conservative and religious opinions on campus.

“Universities are supposed to be marketplaces of ideas. They should be encouraging free speech, not shutting it down,” said Ellen Wittman, an antiabortion advocate and student at Miami University in Ohio who spoke after Mr. Trump.

However, critics warned that the action could effectively impose federal curbs on free speech and further politicize how administrators handle the delicate balance between students’ expression and their safety, such as when controversial speakers come to campus. They also said the executive order could allow political motivations to influence which research projects the federal government funds. Colleges and universities receive tens of billions of dollars annually from the government in the form of research and other education grants.

“I am not quite sure what problem we’re trying to solve,” said Jonathan R. Alger, president of Virginia’s James Madison University, who argued that institutions already take issues of free speech very seriously. “Tying grants to something completely different—in this case, tying science to free speech—it seems like mixing apples and oranges,” he said.

Ted Mitchell, president of the American Council on Education, the largest higher-education trade group in Washington, said the order could lead to “unwanted federal micromanagement of the cutting-edge research that is critical to our nation’s continued vitality and global leadership.”

The directive itself creates no new federal policies; public universities already must comply with the First Amendment, and private schools open themselves to lawsuits whenever they contradict their own published codes of conduct. It is instead designed to warn schools that the administration will be looking to redirect funds or file lawsuits against schools it believes are stifling free expression. The administration has already laid out some of the types of campus policies it finds onerous, through court filings submitted on behalf of plaintiffs suing universities.

In June, for example, the Justice Department filed a “statement of interest” in a suit against the University of Michigan’s antibullying and harassment policies, which the department said limited free speech by being too broad and vague. The plaintiffs, three anonymous students, said the policies made them afraid to espouse “unpopular” conservative views on topics like immigration, gun rights and race relations.

Mark Schlissel, president of the University of Michigan, said the public university already must comply with the First Amendment. “The notion of tying federal funds to specific policies at specific universities is very troubling,” he said.

Policies also contested by the Trump administration include rules on which parts of campus students can use to protest and restrictions on when provocative speakers can visit campus. Critics note that the administration has only intervened in cases where conservative, rather than liberal, students have felt muzzled by university policies

Mr. Trump’s announcement drew a mixed response from others, who said they agreed free speech on campus needed to be defended more robustly, while cautioning against efforts to regulate it.

“Colleges should punish hecklers…and stop coddling students to protect them from disagreeable points of view,” said Sen. Lamar Alexander (R., Tenn.), chairman of the Senate Education Committee. But, he added, “I don’t want to see Congress or the president or the department of anything creating speech codes to define what you can say on campus.”

The free-speech group FIRE, which has defended professors and students of various political leanings, said it would watch closely to see if the order delivers what it promises, or if it instead results in “unintended consequences that threaten free expression and academic freedom.”

The White House is asking federal agencies, such as Health and Human Services and the Department of Defense, to draw up their own guidelines to protect speech, an Office of Management and Budget official said. Those agencies will serve as the arbiters of individual university violations.

Legal analysts said the administration is likely within its rights to make specific campus free-speech protection policies a condition of receiving federal funds. But the federal government would have a tougher time cutting universities off from grants they were previously awarded.

Several conservative states, including North Carolina and Arizona, have imposed their own free-speech requirements that could result in disciplinary action or even jail terms for students who interfere with the free-speech rights of others. Momentum for these laws has largely been driven by the Goldwater Institute, a conservative think tank that has drawn up model legislation on bolstering campus free speech.

Some legal experts also said such overly broad mandates could stifle protest. Students could be punished, for example, for demonstrating outside a professor’s classroom or for holding counter-demonstrations, even though both acts represent expressions of free speech.

“The best answer to protecting speech on campus is generally not more intervention by the government,” said Suzanne Nossel, president of PEN America, a left-leaning group that advocates for more free-speech protections. “These attempts, even if well intended, can inject politics into the process.”