US Navy Adm. William McRaven testifies before the Senate Armed Services Committee in Washington, March 5, 2013. Thomson Reuters

Retired Adm. William McRaven, who led the Joint Special Operations Command before becoming University of Texas System Chancellor, condemned President Donald Trump's repeated attacks on the news media and the press during a speech Tuesday.

"The president said the news media is the enemy of the American people," McRaven said in comments at the inaugural event of the Communication and Leadership Speaker Series at the University of Texas. "This sentiment may be the greatest threat to democracy in my lifetime."

McRaven's remarks were first reported by the Austin American-Statesman and confirmed to Yahoo News by the University of Texas' external relations office.

The comments from McRaven, who is a University of Texas at Austin journalism alumnus, came days after a tweet posted by Trump in which the president denounced "The FAKE NEWS media" — citing The New York Times, NBC, ABC, CBS, and CNN specifically — as "the enemy of the American people."

McRaven has been chancellor for two years, and his comments Tuesday night were not his first to rebuke a Trump policy or comment.

In a statement at the end of January, cited by Yahoo News, McRaven spoke out in favor of immigration, saying, "I believe that the talent, energy, and ideas flowing into the United States of America ... from countries around the world are among our greatest strengths."

"I would hope that my commitment to our nation's security cannot be questioned,” McRaven said in the statement, according to The Daily Texan. “I stand behind our nation’s efforts to ensure all our citizens are free from the threat that terrorism can bring to our shores."

McRaven, a former Navy SEAL, is highly regarded within the special operations community. He was the first SEAL to work in the White House under George W. Bush, where he focused on counterterrorism policy. McRaven was also the architect of the May 1, 2011, raid in northern Pakistani city of Abbottabad during which Osama bin Laden was killed.