The visit to Washington last week of President Xi Jinping, the leader of the world’s second-biggest power, illustrated Lyndon Johnson’s saying that politicians need to be able to “walk and chew gum at the same time.”

The meetings that Xi, the most powerful Chinese leader in decades, held with President Obama almost seemed like a distraction, given the focus on Islamic terrorists, tragedy and dysfunction in the Middle East and the maneuvering of President Vladimir Putin of Russia.

Those all are dire, immediate challenges for the U.S. But for the next generation, the relations between what are likely to be the only two superpowers may be the most important geopolitical issue.

It won’t be easy. The Chinese are certain the U.S. wants to contain and isolate them, and sabotage the ruling Communist Party and its mixed economic model. And they believe the U.S. is determined to dominate their Asian backyard.

The U.S. sees an increasingly assertive China that is cracking down on human and political rights, waging cyberattacks on America’s public and private enterprises, aggressively threatening neighbors in the South China Sea and manipulating its currency for economic advantage.

Robert Blackwill, a former U.S. ambassador to India who could be a policymaker in any future Republican administration, wants the U.S. to adopt a more confrontational posture. He sees China as a threat to America’s economic interests as it amasses military might “capable of both defeating local adversaries and deterring the United States from coming to their defense in a crisis.” At stake, he argues, is “the balance of power in Asia.”

Several Asian countries want the U.S. to serve as a check on China’s power. But they aren’t eager for a confrontation that they would watch from the sidelines. Most now do more trade with China than with the U.S.

One China expert, former Prime Minister Kevin Rudd of Australia, says that though there are differences, both sides tend to exaggerate them. The Chinese, for example, have hugely increased military spending, but the U.S. still spends four times more. “There is no serious prospect of China reaching military parity with the United States before midcentury, if at all,” Rudd, who is president of the Asia Society, wrote this year in a paper for Harvard University’s John F. Kennedy School of Government.

Rudd argues that it’s essential for both sides to search for “constructive engagement” to set rules of the road. The political systems are far apart — China isn’t going to change — and the two powers have competing interests and pressures when it comes to cybersecurity and the quest for regional advantage. There also are important shared interests: economic interdependence, climate change and the terrorist threat.

Domestic considerations will shape these possibilities. In China, Xi has consolidated his power. Yet the economy has slowed to a 6 percent annual growth rate, from 10 percent to 12 percent, and the Communist leader is cracking down on pervasive corruption. Both efforts threaten powerful arrangements, which might cause internal disruptions, even further restrictions on human and political rights or more aggression in the South China Sea or toward Taiwan.

On the other side of the Pacific, if Donald Trump or the right wing of the Republican Party prevails, tensions will escalate.

The rhetoric and pronouncements from last week’s meetings were encouraging, as China vowed to rein in cyberattacks and made further commitments on climate change. But two years ago, the two leaders hailed their discussions at Sunnylands, in California — Obama called them “terrific.” These, too, included agreements on cybersecurity. Yet since that meeting, the U.S. suspects that Chinese hackers stole the government personnel files of more than 20 million Americans. The next few months will show whether this time will be different.

Above all is the need for both sides to appreciate what the Harvard scholar Graham Allison calls the “Thucydides trap,” in which rising great powers often end up at war with established great powers.