With less than a week to go before the midterm elections, President Donald Trump is warning darkly of an imminent immigrant “invasion,” deploying thousands of troops to the U.S.-Mexico border, releasing a racist ad on Twitter, and threatening to issue an executive order aimed at ending birthright citizenship.

The president has, in pundit-speak, found his “closing argument” for the 2018 campaign season.

Indeed, many savvy observers in recent weeks have interpreted Trump’s efforts to inflame national tensions around immigration as a desperate, last-ditch ploy to save his party’s at-risk congressional majorities. But while the president himself may be acting on some mix of impulse and improv, the roots of the strategy go deeper—and its architects in the West Wing are looking far beyond the current election cycle.

To understand the thinking behind Trump’s gambit, it is necessary to spend a few minutes inside the head of Stephen Miller, the 33-year-old speechwriter and senior policy adviser to the president. A fierce immigration hawk who’s championed a right-wing nationalist agenda, Miller is Trump’s most trusted adviser on immigration, and he is constantly looking for new ways to push his policy priorities into the national spotlight. Earlier this year, it was reported that Miller was leading an effort within the administration to crack down on immigrants in the run-up to the midterms. And as Politicoreported Wednesday, Trump’s latest string of provocations—from the immigrant-caravan scaremongering to the likely unconstitutional executive order—represents a “dream come true” for Miller.

According to Miller, Trump benefits politically any time Americans are focused on immigration—no matter how bad the headlines, no matter how bleak the polls, no matter how big the controversy. “You have one party that’s in favor of open borders, and you have one party that wants to secure the border,” he told The New York Times earlier this year. “And all day long the American people are going to side with the party that wants to secure the border. And not by a little bit. Not 55–45. 60–40. 70–30. 80–20. I’m talking 90–10 on that.”

.. Even setting aside the hyperbole, this view of the electorate is debatable. (Voters seem to have given Trump mixed reviews on his handling of the caravan, for example.) But it’s still worth understanding how Miller lays out his political calculus. While he may be a committed ideologue, he works for and with a lot of Republicans who are guided more by opportunism than by ironclad conviction when it comes to immigration. The long-term relevance of his sharply nativist politics within the GOP will depend in part on the Miller faction’s ability to keep selling it as a winning strategy (even in the face of evidence to the contrary).

.. “The future of the Republican Party should be tapping into … the feeling of belonging and meaning and pride that comes with being part of this whole ‘America First’ movement,” he told me. “There’s something really beautiful about people from all different walks of life … who are bound together by this big idea about American identity, and American unity, and American interests.”

.. Continuing in concern-troll mode, Miller said, “I think one of the big challenges facing modern liberalism is that there’s not a great emotional appeal to an international identity, like a citizen-of-the-world identity.”

.. “Look, the current nation-state model is the product of thousands of years of political, social, and cultural evolution,” Miller said. “I mean, it was only recently, in like the last few decades, that people have tried to create an organizing principle larger than the nation-state.” The desire to root for your own native country is “intrinsic” to human nature, he told me. “You see that flag, you sing the national anthem, or you hear your team wins the gold medal … it creates a kind of pride in you that is really hard to translate.”

.. “Find today your most liberal friend, and ask them this question: Who has more of a right to a job in America—a U.S. citizen, or an illegal immigrant? And if they don’t say U.S. citizen like that”—Miller snapped his fingers—“then that means on some philosophical level they find the idea of America First objectionable.”

.. “But the idea of having official membership in the nation-state, and therefore that state has an obligation to protect you”—that was the big idea he believed voters would keep coming back for. Voters feel that connection at a visceral level, Miller suggested, and in the end they would always side with a president offering that appeal.