Donald Trump is the most profane major-party candidate ever to run for president, but his short-term political salvation still lies with the religious right. Even after winning enough delegates in the primaries to become the presumptive Republican nominee, the author of The Art of the Deal is still having a hard time closing the deal, still swatting down talk of a Republican Convention coup and clouded by revelations of his near-total failures in fundraising. Trump desperately needs to convince Republicans to stick with him, and it looks like the glue that he’s settled on is, incongruous as it seems, religious tribalism.

Trump’s Islamophobic response to the Orlando massacre is meeting with a much warmer reception inside the GOP than among the general public. And this week, he’s begun aggressively framing his attacks on Hillary Clinton in religious terms as well. This is Donald Trump’s version of a holy war.

To say that Trump makes an unlikely defender of Christian civilization is to understate the matter considerably. Culturally, he’s further outside the religious mainstream than any American politician ever, even the early Deist presidents. His clumsy attempts to score points with the religious right have often displayed his theological illiteracy: There was the time when he almost put money in a communion plate, or when he seemed to think that Christians regard asking for God’s forgiveness as a sign of failed morality rather than a recognition of our fallen condition.

More broadly, though, everything about Trump is an inversion of traditional Christian morality. Boastfulness? Lewdness? Greed? Contempt for those less fortunate (the “losers and haters” he mocks on Twitter)? Gleeful vindictiveness? He’s the whole package. The vast contradictions inherent in the notion of Trump as Christian champion could be seen in a photo tweeted out by Jerry Falwell Jr. on Tuesday, showing Trump, Falwell, and Falwell’s wife Becki all smiling in fellowship, against a wall at Trump Tower full of framed magazine covers featuring Trump—including one from Playboy, a magazine forbidden on the campus of Falwell’s Liberty University.

But evangelicals like Falwell are a core part of the Republican coalition that Trump has to lead. In order to hold that fraying coalition together, he has to find common enemies to rally against because he doesn’t have an appeal to them otherwise. He’s found them: Hillary Clinton and Islam.

On Tuesday, Trump questioned Clinton’s Christianity in the most direct way: “Now, she’s been in the public eye for years and years, and yet there’s no—there’s nothing out there,” he told the assembled clergy and lay leaders. “There’s like nothing out there. It’s going to be an extension of Obama, but it’s going to be worse, because with Obama you had your guard up. With Hillary you don’t, and it’s going to be worse.” Trump then broadened his critique to American leaders in general, whom he accused of not defending Christianity, saying, “All of your leaders are selling Christianity down the tubes, selling the evangelicals down the tubes.”

The speech had all the classic Trump hallmarks. He’s previously attacked the religious faiths of Obama (supposedly a secret Muslim), Ben Carson, Ted Cruz, and Mitt Romney, so it was a familiar move to suggest that the mainstream Methodist Clinton was not a real Christian.

The underlying message of these attacks is often missed: Trump is not just engaged in crude denigration of a rival, he is also recasting Christianity by making it a matter of tribal identity rather than theological agreement or proper behavior (both criteria where he’d lose).

In Trump’s rhetoric, Christianity is like nationalism, a matter of us-versus-them. Trump wants evangelicals to know he’s on their side and that his rivals are part of the amorphous “them”—the people who are, he said Tuesday, “selling Christianity down the tubes.”

Trump’s response to the Orlando massacre also showed how he’s relying on religious tribalism to keep the GOP together—even if that means alienating the general electorate. Trump suffered in the polls after Orlando because 51 percent of Americans disapproved of his approach to the massacre, which included a new call for banning Muslim immigrants and suggestions that Obama is a covert sympathizer with ISIS. Only one-quarter of the public approved of these antics. But in the Republican Party, the reverse was true: 50 percent approved of Trump’s response and only 26 percent disapproved. (It’s noteworthy that some putatively “Never Trump” conservative intellectuals, chief among them Hugh Hewett, were impressed by Trump’s response to Orlando.)

As Trump tries to prevent open revolt by the party, the option of religious war is attractive—and the “war” part of it, at least, comes naturally to the candidate. And he may be able to keep the party with him if he suggests that Clinton is a heretic or pagan, no better than Obama, or casts the war on terror as a struggle against the foreign creed of Islam. Trump’s long-term problem is that this sort of sectarian appeal will alienate the larger electorate. But given that fact that his campaign is in deep disarray, and still faces opposition by major forces in the Republican party, he has no choice. He has to wage religious wars now, even at the cost of secular votes in November.