WASHINGTON — In a veiled rebuke of President Trump, former Secretary of State Rex W. Tillerson warned on Wednesday that American democracy was threatened by a growing “crisis of ethics and integrity.”

“If our leaders seek to conceal the truth, or we as people become accepting of alternative realities that are no longer grounded in facts, then we as American citizens are on a pathway to relinquishing our freedom,” he said in a commencement address at the Virginia Military Institute in Lexington, Va.

Even small falsehoods and exaggerations are problematic, Mr. Tillerson said. He did not mention Mr. Trump by name, although the president is prone to both.

“When we as people, a free people, go wobbly on the truth even on what may seem the most trivial matters, we go wobbly on America,” he said.

Mr. Tillerson arrived in Washington after running Exxon Mobil, one of the world’s largest corporations, backed by business leaders and some foreign policy experts as a man who could bring experience and ballast to an untested administration.

But as the nation’s top diplomat, he soon found himself at odds with the president over a variety of issues, including negotiating with North Korea and extending the Iran nuclear deal, and privately humiliated until he was fired by a tweet.

Since then, he has largely been in seclusion at his Texas ranch. He had agreed to deliver the V.M.I. commencement address before he was fired.

In his address, he cut to the heart of the most significant criticisms of the president, that Mr. Trump exaggerates and constructs his own truths and that he has undermined ethical standards in Washington.

“If we do not as Americans confront the crisis of ethics and integrity in our society and among our leaders in both the public and private sector — and regrettably at times even the nonprofit sector — then American democracy as we know it is entering its twilight years,” Mr. Tillerson warned.

Mr. Tillerson’s 14-month tenure at the State Department was marked by conflict with Mr. Trump and an exodus of some of the nation’s most experienced diplomats. In the months before his own departure, Mr. Tillerson admitted he had only belatedly learned to enjoy the job — perhaps unsurprising, given that he was at one point notably rebuffed by presidential tweet on North Korea and, at another, forced to deny that he had called Mr. Trump a “moron.”

He and Mr. Trump disagreed on an array of specific issues, from the Paris climate accord to free trade. He seemed to reference some of those disputes in his speech on Wednesday, reminding his audience that the United States gets much of its strength from a network of alliances.

“One of America’s great advantages is we have many allies,” he said. “Our adversaries — China, Russia, Iran and the terrorist organizations — have few.”

Relations with Europe are at their lowest point in years, bedeviled by a series of disagreements with the Trump administration over the climate accord, the Iran deal and trade disputes. Mr. Tillerson suggested this was problematic.

“We must never take these long-held allies for granted,” he said. “We must motivate and strengthen them — not just in our areas of complete agreement, but particularly in bridging our differences both in trading relations and in national security matters.”

Mr. Tillerson made a full-throated appeal for the benefits of free trade, warning of the “anxiety and fear about growth in foreign markets and about the global movement of jobs.”

He said that “every nation has a right to aspire to a better quality of life, and that free trade and economic growth are the means by which opportunity is created for all people.” It was a notable defense of free trade and developing nations from a veteran of an administration that has threatened to rip up the North American Free Trade Agreement and impose billions of dollars in tariffs on rivals and allies alike, and uses “America First” as its guiding principle.

Mr. Tillerson also said citizens must demand that America’s future be “fact-based, not based on wishful thinking, not hoped-for outcomes made in shallow promises, but with a cleareyed view of the facts as they are and guided by the truth that will set us free to seek solutions to our most daunting challenges.”

In Washington, just moments before Mr. Tillerson began speaking, his successor, Mike Pompeo, was holding his first meeting with the entire staff of the State Department. In his own prepared remarks, Mr. Pompeo made clear that he intended to make a sharp break from Mr. Tillerson’s tenure.

“It would be silly today to lay out for you my ‘grand strategy’ for the State Department. I have too much to learn,” Mr. Pompeo said in a dose of humility many diplomats later said was welcome. “Nor will I tick off country-by-country threats. You know all that.”

It was a reference to Mr. Tillerson’s own first all-hands meeting at the department, which had amounted to a wide-ranging lecture on world affairs. Mr. Pompeo did not mention Mr. Tillerson by name but said he would not try to school a building full of professional diplomats.

Mr. Pompeo promised to bring the State Department’s “swagger back,” which he said on Wednesday was an “aggressiveness born of the righteous knowledge that our cause is just, special and built upon America’s core principles.”

“We should carry that diplomatic swagger to the ends of the Earth, humbly, nobly and with the skill and courage I know you all possess,” he said.

Back at the V.M.I. campus, Mr. Tillerson told the graduating cadets that as they entered the world, they must “carefully consider the values and the culture of the organizations in which you seek to work.”

“Look for employers who set high standards for ethical conduct,” he said.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Tillerson, in Swipe at President, Says ‘Crisis of Ethics’ Infects U.S.. Order Reprints | Today’s Paper | Subscribe