Donald Trump is not all wrong about China. That gives his administration an opportunity to reshape what, if not handled carefully, could become the world’s most dangerous bilateral relationship.

During the presidential campaign, Trump was mostly off-base in his assessment of the world. NATO is not obsolete. Japan and South Korea are not freeloaders. Trade among Mexico, Canada and the United States has been good for all three countries.

He was wrong in many particulars about China, too. It is not, for example, a currency manipulator as Trump asserts.

But his underlying message of basic unfairness was right. China is not operating by the same rules as everyone else. When President Clinton promoted China’s entry into the World Trade Organization, the expectation was that China would grow more prosperous — and, in the process, more economically liberal and politically tolerant.

The first prediction has proved true, which by itself is enough to justify the West’s decision. Globalization has helped China bring hundreds of millions of people out of poverty, an unprecedented achievement of human progress. The country is stable and at peace, no small thing given its turbulent history. Many of its problems — smog, traffic, school access — are challenges of a middle class that barely existed two decades ago.

But the Communist Party is becoming more repressive, not less. Tibetans and Uighurs are more at risk. The Internet has become a tool of control, not a window to the world. The space for honest journalism and academic debate is being steadily squeezed. China has stepped up the bullying of its neighbors and its unilateral territorial claims.

Meanwhile the Chinese economy, tantalizing as always to foreign investors, is far from open. China has found ways to suck technology from Western companies without giving them equal access to its markets. In the information business, it tightly restricts how many journalists — and even which ones — are permitted into China, and keeps its people from reading much of their work, while its propaganda outlets face no comparable obstacles in the West. Now, bolstered by their home-field advantage, Chinese companies are investing overseas in markets that remain mostly open to them.

It’s easy to describe how not to respond to all of this. Initiating a trade war, by slapping tariffs on Chinese products, would likely harm Chinese and Americans alike without accomplishing much. The United States should not make it easy for China’s regime to portray the United States as hostile to the Chinese people.

Nor should the Trump administration tilt the other way and seek some grand deal with China’s regime at the expense of the Chinese people or the United States’ democratic allies.

Trump provided a case study of how not to do things when he chatted by phone with Taiwan’s president. The conversation itself, though a departure from convention, was not unreasonable: Taiwan is a democratic ally, so why shouldn’t the two leaders talk?

But Trump followed the conversation with a tweet that positioned the phone call, which angered China’s rulers, as payback for Chinese misbehavior: “Did China ask us if it was OK to devalue their currency (making it hard for our companies to compete), heavily tax our products going into their country (the U.S. doesn’t tax them) or to build a massive military complex in the middle of the South China Sea?” he asked. “I don’t think so!”

So if China behaved better, would Trump cold-shoulder Taiwan? Would he ask Beijing’s permission before taking another call? That’s precisely the wrong message.

In the long run, the greatest cost of China’s backsliding will be self-imposed. Many China hands in the West cheered the prospect of President Xi Jinping postponing political reform in order to impose economic reforms. But for the most part, economic reforms haven’t materialized, and they won’t without more political freedom. To reach the next stage of prosperity, China needs more entrepreneurship, more creativity and more of the predictability that only rule of law can deliver. None of these are possible in a stifling one-party state.

The Trump administration can’t chart China’s course. But it can have some influence if it engages more actively in the region and stays faithful to American values and those of democratic allies. Attention to human rights shouldn’t be traded away for economic concessions; on the contrary, free-market principles and political liberty are on the same side of the coin.

Trump should insist on more reciprocity in economic relations, but consistent with fairness and principles of economic freedom, not simply to gain an upper hand. American workers and firms would benefit, but the Chinese people would benefit most of all.

Read more from Fred Hiatt’s archive, follow him on Twitter or subscribe to his updates on Facebook.