A fan holds a sign supporting President Trump in the stands during an NFL football game between the Pittsburgh Steelers and the Jacksonville Jaguars on Oct. 8 in Pittsburgh. (Don Wright/AP)

Correction: An earlier version of this piece misattributed a quote about the book “The Spectacular State.” This version has been updated.

Brian Klaas is a fellow in comparative politics at the London School of Economics and the author of “The Despot’s Accomplice: How the West is Aiding and Abetting the Decline of Democracy.”

North Korea is threatening nuclear war with the United States. Three-and-a-half million Puerto Ricans are still struggling to overcome the damage from Hurricane Maria. Californians are reeling from a devastating wave of wildfires. Las Vegas just experienced the worst mass shooting in modern U.S. history. And rather than delivering on his promise to sign 10 major bills in his first 100 days in office, President Trump has signed no major legislation after 272 days in office.

Good thing the president is focused on denouncing National Football League players who kneel during the national anthem to protest racial injustice.

Make no mistake: Trump’s Twitter war against the NFL is a calculated, cynical strategy to divert attention from his administration’s failures and scandals. Worse, though, it’s authoritarian. His cynical use of the anthem controversy to stir up cultural division is straight out of a playbook used by the world’s dictators.

Earlier this week he said players should be forced to stand, a flagrant assault on the freedom of expression. NFL owners have pushed back by saying they won’t punish players who choose to take part in the protest; the Constitution is clearly on their side. Yet Alabama senatorial candidate Roy Moore, a Republican, has poured fuel on the fire by bizarrely declaring that kneeling during the anthem is “against the law.” Trump is undoubtedly grateful. No one needs distractions right now more than he does.

Since Sept. 20, when Hurricane Maria made landfall — and around the time that his health care proposal crashed and burned in the Senate — Trump has tweeted about the NFL 19 times. Twenty-one of his tweets in that period mentioned the national anthem. Eleven mentioned the flag.

Picking a fight with the NFL may seem like an irrational strategy. It’s not. Instead, it’s strikingly familiar to anyone who has lived in the shadow of an authoritarian strongman.

Public loyalty rituals are as fundamental to despotism as voting is to democracy. Under Mao in China, citizens were expected to always carry a Little Red Book around with them. In Franco’s Spain, citizens were pressured to display photographs of the dictator to prove their loyalty to the regime. And in North Korea, citizens who do not clap loudly enough at public loyalty rituals may face execution. As one former North Korean soldier put it: “You chant ‘Long Live’ and clap because you don’t want to die.”

Certainly, Americans are still a long way from full-fledged autocracy. Yet Trump’s cynical loyalty test is yet another example of how he mimics despotic leaders, this time by falsely conflating dissent against the government with hatred of the nation.

Of course, patriotism can be a powerful unifying force. I have always stood for the national anthem when I go to sporting events, as a sign of respect to those who have sacrificed so much so that I have a genuine choice in the matter. But forcing people to stand for the anthem and the flag negates every freedom those symbols represent.

Democratic freedom means the freedom to sit during the anthem, the freedom to refuse to clap when the president passes by, and the freedom to criticize him openly without fear of retribution or job loss. Freedom is meaningless if only popular forms of political speech are allowed.

So, why has Trump emphasized this feud so much? He understands that most of the country disapproves of him. He’s aware that his administration has failed to deliver on any major legislative promise, even though his party controls every branch of government. And he knows that swirling scandals and countless investigations are imperiling his presidency.

For despots and aspiring despots, the tried and true strategy to deflect blame and buy time is to divide and rule. For the strategy to be effective, it must either draw attention away from negative stories that threaten the administration, or it must whip up nationalist fervor, ideally against an ethnic or religious minority. Trump’s attack on African American NFL players ticks all those boxes.

In a 2016 article, the writer Sarah Kendzior referenced a book by Laura Adams called “The Spectacular State,” which explains how authoritarian populists manage to generate public support even when they are failing to deliver for the people. In many instances, their success is tied to cloaking themselves in the flag and spectacles of patriotism. As Kendzior put it: “The nation becomes a brand; the dictator, a brand ambassador; the people, a captive audience.”

For all of Trump’s failings, he knows how to be a brand ambassador.

Mark Twain famously said that “Patriotism is supporting your country all the time, and your government when it deserves it.”

Twain was right. But you don’t have to take my word for it, or even Mark Twain’s — you can take Donald Trump’s. He tweeted that very quote in January 2014, in his own endorsement of protests against the Obama administration.

If the U.S. flag and national anthem stand for anything, it is that our democracy allows us to engage in dissent and protest without fear. The best way to honor the memory of our fallen heroes is to honor what they fought to protect: our democracy.