Assailed for inflaming racial divisions, Mr. Trump this week sought to reframe his attack on the so-called squad of congresswomen into a question of patriotism and loyalty, claiming that they “hate our country.”

The blistering debate that has followed is all the more remarkable given that Mr. Trump spent much of the last few years essentially disparaging America. It was the high-octane fuel for his campaign, the notion that this was no longer the United States of old because it had succumbed to politically correct, multicultural, open-borders globalism and allowed itself to be taken advantage of by allies and adversaries alike.

As president, however, Mr. Trump has wrapped himself in the flag — at one point hugging it at a conservative political gathering — and waged a monthslong campaign against African-American football players for protesting racism by kneeling during the national anthem. He effectively co-opted the national celebration of the Fourth of July, making himself the red-white-and-blue star on center stage. He has contended that he has transformed the United States into a beacon of strength again, crediting himself with reversing the national decline he identified as a candidate.

“As president, he now sees America as an avatar for himself — it must be great because he’s great,” said Nicole Hemmer, a scholar of conservatism who is taking a position at Columbia University to work on its oral history of Barack Obama’s presidency. “From this perspective, to allow that America has faults would be to allow that Trump himself has them, something he has never been willing to do.”

In a way, this is a struggle over what the United States really stands for. Mr. Trump and his allies argue that the squad and its followers do not share core American values because they are critical of the system and advocate or flirt with socialism, while the president’s critics say it’s the other way around and that he does not subscribe to the core national beliefs in free speech, immigration and the rule of law. At stake is who gets to define what constitutes Americanism.