By Adam Sahw, Fox News–

President Trump on Thursday signed an executive order to promote free speech on college campuses by threatening colleges with the loss of federal research funding if they do not protect those rights.

“We’re here to take historic action to defend American students and American values,” Trump said, surrounded by conservative student activists at the signing ceremony. “They’ve been under siege.”

“Under the guise of speech codes, safe spaces and trigger warnings, these universities have tried to restrict free thought, impose total conformity and shut down the voices of great young Americans like those here today,” he said.

A senior administration official said the order directs 12 grant-making agencies to use their authority in coordination with the White House Office of Management and Budget (OMB) to ensure institutions that receive federal research or education grants promote free speech and free inquiry. White House officials say it will apply to more than $35 billion in grants.

Public universities seeking funding would have to certify that they comply with the First Amendment, which already applies to them. Private universities, which have more flexibility in limiting speech, would need to commit to their own institutional rules.

“Even as universities have received billions and billions of dollars from taxpayers, many have become increasingly hostile to free speech and the First Amendment,” Trump said.

Trump had announced that such an order was forthcoming at the Conservative Political Action Conference last month, where he said the directive would require colleges and universities to support free speech in exchange for federal research dollars.

He brought on stage Hayden Williams, a conservative activist who was attacked while working a recruitment table on campus at the University of California-Berkeley. The video quickly went viral, with conservatives citing it as further evidence of the stifling and sometimes-violent atmosphere that conservatives face on campus.

“He took a punch for all of us,” Trump said of Williams. “And we could never allow that to happen. And here is, in closing with Hayden, here’s the good news. He’s going to be a wealthy young man.”

OPINION: TRUMP ORDER PROTECTING CAMPUS FREE SPEECH IS RIGHT RESPONSE TO BERKELEY ASSAULT

“If they want our dollars, and we give it to them by the billions, they’ve got to allow people like Hayden and many other great young people and old people to speak,” Trump said. “Free speech. If they don’t, it will be costly. That will be signed soon.”

Conservative commentators such as Ann Coulter and Ben Shapiro have faced hostile atmospheres when attempting to speak at universities — particularly Berkeley, where Coulter was forced to pull out of speaking and Shapiro was faced with protests that required police in full riot gear and intense security measures.

White House officials declined to provide specific examples about how universities could lose funding and said implementation details will be finalized in coming months.

Fox News’ Kellianne Jones, Robert Gearty and The Associated Press contributed to this report.