James Hohmann is a national political correspondent for The Washington Post and the author of the Daily 202 newsletter.

Jeff Flake took Donald Trump’s attacks on Mexican and Muslim immigrants personally during the 2016 campaign. They were among the many reasons that the Republican senator from Arizona could not bear to vote for his party’s presidential nominee and why he’s now written a stinging anti-Trump polemic, even though it will make winning reelection next year more difficult.

The most newsworthy parts of Flake’s new book, “Conscience of a Conservative,” are his frontal attacks on the president. He writes that the GOP’s “Faustian bargain” to embrace Trump as a way to advance its agenda has backfired by putting sacred institutions and the rule of law at risk. He refers to Trump as a carnival barker, expresses alarm about the president’s affection for authoritarian rulers and calls out his Republican colleagues in Congress as enablers.

But the book is at its most compelling when Flake shows how he developed the conservative worldview that would make Trump so anathema to him. It was his experience as a worker on his family’s ranch, as a Mormon missionary in Africa and as the executive director of the Goldwater Institute in Phoenix, where he worked closely with his political hero, Barry Goldwater, in the years before he died.

The 54-year-old Flake often asks himself, “What would Goldwater do?” And he feels certain that the 1964 Republican presidential nominee, to whom Trump has often been compared, “would not be pleased or amused” by the president or the state of the conservative movement.

Flake’s faith is an important part of his narrative. In 1838, the governor of Missouri signed an “extermination” order that made it legal to kill anyone who belonged to the Church of Jesus Christ of Latter-day Saints. His ancestors faced persecution as they moved west and settled in Arizona. The senator volunteers that his great-great-grandfather endured six months of hard labor in a Yuma prison for having a second wife. “When we say ‘No Muslims’ or ‘No Mexicans,’ we may as well say ‘No Mormons,’ ” Flake writes. “Because it is no different.”

To make the case against Trump’s travel ban, the senator recalls how two surgeons from predominantly Muslim countries saved his father-in-law’s life after a heart attack.

The weekend after Trump proposed his ban in December 2015 on Muslims entering the United States, Flake felt called to attend afternoon prayers at a mosque in Scottsdale so he could let the parishioners know that most Americans are not given to such intolerance. George W. Bush sent him a note the next day. “Thank you for your voice of reason in these unreasonable times,” the former president wrote.

But the unreasonable times continued. “During the campaign, I assumed that this shocking episode — among so many more — would be a political blunder from which Donald Trump would never recover,” Flake admits. “I readily concede that I got the politics wrong. I will even concede that I underestimated the populist appeal of Trump’s proposed Muslim ban. But I will not concede the underlying principle of religious freedom.”

Growing up on a farm that employed migrant laborers, Flake got to know undocumented immigrants as hard workers, not criminals, who lived in constant fear of deportation. “Our mechanic Manuel was taken back to Mexico by the Border Patrol nineteen times,” Flake notes. “My life was made far more difficult during the middle of summer when the Border Patrol would raid our farm. Sometimes the Border Patrol would send small planes to search our alfalfa fields for migrants. When I would hear the distinctive whine of the Cessna, I’d hop on a horse, put on a hat that would obscure my head, and try to divert the Border Patrol away from our workers — a decoy in the game of cat and mouse.”

He remains proud of his role in the Gang of Eight, which negotiated a bipartisan compromise to overhaul the immigration system in 2013. It would have allowed millions of illegal immigrants to live legally in the United States and to eventually become citizens, in exchange for the construction of 700 miles of fencing on the southern border and a doubling of the number of Border Patrol agents. The bill passed the Senate but went nowhere in the House.

Flake became inspired to write this book during a trip to Mexico City two weeks after the election, as he struggled to soothe the concerns of Mexican leaders about NAFTA, the proposed border wall and anti-immigrant sentiments.

(Dalton Bennett,Kate Woodsome/The Washington Post)

“We have given in to the politics of anger — the belief that riling up the base can make up for failed attempts to broaden the electorate,” he writes. “These are the spasms of a dying party. Anger and resentment and blaming groups of people for our problems might work politically in the short term, but it’s a dangerous impulse in a pluralistic society, and we know from history that it’s an impulse that, once acted upon, never ends well.”

As a devoted conservative from a border state, Flake fears from a political standpoint that alienating Latinos will destroy the GOP. “We are skidding with each passing election toward irrelevance in terms of appealing to a broad electorate,” he writes. “We knew all of this before the last election, but we quickly set it aside for the sugar high of populism, nativism, and demagoguery. The crash from this sugar high will be particularly unpleasant.”

Publishing this book is a true act of political courage. Many conservative intellectuals have cogently made the case against Trumpism since the billionaire came down the escalator at Trump Tower two summers ago, but Flake is the first sitting senator to do so in book form since the president took office. Sen. Ben Sasse (R-Neb.), who declined to endorse Trump last year, tweets a fair amount of criticism, but his recent book “The Vanishing American Adult” steered clear of the president. And he’s not up for reelection until 2020.

Flake was already facing a tough primary race next year, and this ensures that it will be more challenging. The White House political team has been actively talking with potential GOP challengers, with the goal of coalescing behind the most credible contender who could defeat him. Trump has reportedly told people that he’ll put up $10 million of his own money to help.

The senator mostly wrote his manifesto in secret. He did not even tell some of his advisers that he was working on it, lest they try to talk him out of putting these ideas on paper.

“I feel compelled to declare: This is not who we are,” Flake writes. “Too often, we observe the unfolding drama along with the rest of the country, passively, all but saying, ‘Someone should do something!’ without seeming to realize that that someone is us. . . . The question is: Will enough of us stand up and wrest it back before it is too late? Or will we just go along with it, for our many and varied reasons? Those are open and unresolved questions.”

What Flake will do next is also an open and unresolved question. Liberals will complain that his actions don’t match his talk. If he thinks the president is as dangerous as he lays out in the book, why isn’t he more aggressively trying to check him from his perch on Capitol Hill?

It seems almost inevitable that Flake will back off some of his strongest rhetorical broadsides, at least until he gets through the GOP primary. In television and radio interviews to promote his book, he’s often not gone as far as he does in its pages.

But Flake has laid down an important marker, and he deserves credit for taking a brave stand when the politically convenient thing is for him to bite his lip. He has created a permission structure for Republican senators with safer seats to express publicly what they often tell reporters privately.

As future generations study this tumultuous time, “Conscience of a Conservative” — in many ways a sequel to Goldwater’s 1960 book of the same title — will be an important data point. “The historians will sort out what exactly happened in this interregnum — this lapse of principle, this period of drift — they will name it,” Flake writes. “It is a testament to just how far we fell in 2016 that to resist the fever and to stand up for conservatism seemed a radical act.”