From the time Mao Zedong seized power 70 years ago until today, Chinese leaders have staked their claim to rule on safeguarding the nation against foreign adversaries after a history of invasion and occupation. With the founding of the People’s Republic of China in 1949, Mao declared: “Ours will no longer be a nation subject to insult and humiliation. We have stood up.” After the political crisis in 1989 and the widespread disillusionment that followed the brutal crackdown at Tiananmen Square, the Chinese Communist Party began a nationwide patriotic education campaign to encourage pride in China’s achievements and in the party for helping the country overcome a “century of national humiliation.”

Such propaganda has been surprisingly effective at creating room for the government to maneuver amid international challenges. For example, in 2013, as tensions escalated with Japan, instead of using force, Beijing employed fiery words and demanded that foreign aircraft identify themselves and comply with Chinese instructions when flying over the East China Sea. In 2001, after a midair collision with an American spy plane, China defused the crisis by mourning the “martyred” pilot while avoiding a repeat of the anti-American demonstrations that had swept the country in 1999. In my research, I have found that the government has helped shore up public approval by reminding citizens of the nation’s long struggle and emphasizing that China will ultimately prevail by biding its time for future success.

Yet this strategy has costs. Chinese leaders risk tying their hands in the long run if invoking historical grievances hardens the public’s desire for vindication in the future. Opinion polls show that the public is hawkish on territorial disputes and American military operations in Asia, making it hard for Beijing to reassure the region that its intentions are peaceful. And each time the government spins up and then winds down nationalist anger, whether online or in the streets, it breeds resentment against its heavy-handed manipulation. Blanketing the airwaves and the internet with propaganda may foster the appearance of conformity, but it also hides public disenchantment.

And under Mr. Xi, nationalism has taken on a particularly virulent form. The government has detained more than a million of its Muslim minorities in Xinjiang Province and sought to “Sinicize religion” by replacing expressions of ethnic and religious identity with patriotic slogans. Meanwhile, the Chinese Communist Party’s attempts to inculcate loyalty and squelch opposition among the diaspora in Taiwan and Hong Kong have aroused concerns that Beijing cares more about its vision of ethnic unity than respect for sovereignty and the rule of law. These efforts may bolster the hand of those in the United States promoting a new “red scare” that targets ethnic Chinese and policies that restrict scientific research on the basis of national origin.

For all of Mr. Xi’s rhetoric about “a China solution to humani­ty’s search for better social systems,” the Chinese Communist Party has not tried to export its ideology or system of government, unlike Soviet efforts to spread communism or American programs to promote democracy. In seeking to make the world safer for the party, Beijing has made it easier for authoritarian states to coexist alongside democracies. Mr. Xi’s overriding focus is not on spreading his brand of autocracy, but on eliminating risks to his rule at home and securing his nation’s economic growth and security.