It's prudent to tread carefully around disagreements with an adversary whom we also need as a partner. It is imprudent and unacceptable, however, to endorse a rival nation's misdeeds.

President Trump crossed that line with China this week, ignoring Beijing's human rights abuses and territorial aggressions, while applauding the Chinese leader's accumulation of power.

During his two day visit to China, where the Communist Party holds a monopoly of power in an iron grip, Trump lauded President Xi Jinping as "a very special man," telling him "my feeling toward you is an incredibly warm one." Ignoring China's military campaign in the South and East China Seas, our president claimed that "the military parade this morning was magnificent, and the world was watching ... Nothing you can see is so beautiful."

On Thursday, Trump and Xi failed to take media questions after delivering press statements. Former President Barack Obama made that same mistake in his first visit to China. Other American presidents have used their China visits as a rare chance to put the Communist Party leader before an adversarial press — something that doesn't occur often in that repressive country.

This followed Trump's bizarre Twitter post congratulating Xi on "his great political victory," which was, in truth, an authoritarian power grab.

Realism requires Trump to form effective working relationships with foreign leaders of all ideologies. This is a fact of realpolitik that should be recognized. But there is a difference between Japanese Prime Minister Shinzo Abe and the Chinese president. China has very little political freedom and still enforces curbs on religious exercise and large families.

Imagine those Chinese dissidents watching Trump's behavior in China. Many of them probably felt America had abandoned them, and they no one could blame them if they did.

Alliances are crucial, and we need China's help on North Korea. Sometimes, foreign policy requires doing business with unpleasant or evil regimes. But the Shining City on a Hill cannot trumpet support for a tyranny's evil deeds.

America's historic sacrifices for freedom define this nation and must, to a significant extent, define our foreign policy.

Unfortunately, Trump's deference to Xi is only part of a broader pattern. Yes, President Vladimir Putin of Russia has received Trump's most sustained praise, but other authoritarians have also benefited.

Trump claims to find it a "great honor and privilege" to call President Recep Tayyip Erdogan of Turkey a "friend," even though Erdogan undercuts American interests, imprisons thousands of political opponents, and uses his bodyguards to attack peaceful protesters.

Trump says President Rodrigo Duterte of the Philippines, who has killed thousands of drug users, is a leader who has done "an unbelievable job."

This is too much.

The problem is not that Trump is seeking a good working relationship with more or less tyrannical leaders, it is that he implicitly endorses their bad behavior.

Where an American president shows a lack of interest in basic democratic values, two consequences follow. First, foreign authoritarians find fewer reasons to avoid more aggressive crackdowns on political opponents. Second, the City on the Hill shines less brilliantly.

Thus far in his presidency, Trump has taken decisive action to deter the use of chemical weapons and to crush the Islamic State terrorist group. If he can do that, he can find his voice to stand up to authoritarians, and certainly can avoid applauding their authoritarianism.