Before there was Trump, there was Steve King.

First elected to Congress in 2002, the Iowa Republican found that his brand of anti-immigrant and frequently racist nationalism had traction in the GOP, enough to make him a thorn in the side of Republican leadership and to defeat attempts at immigration reform.

TV personality Donald Trump, who had been transitioning from a supporter of abortion rights and universal health care into a fire-breathing right-winger, took notice of King in 2011 and adopted his politics as the basis for his 2016 presidential campaign.

“I’m here to support Steve King, a special guy, a smart person with really the right views on almost everything,” Trump said at an event in Iowa for King in October, 2014. They were so like-minded “we don’t really have to compare notes,” Trump added, previewing what would become his campaign slogan: “I want to see someone who’s going to make our country great again, which is basically the same thing as Steve.”

It is for this reason that I see a glimmer of light this week, even as our country faces its darkest hour in half a century or more: the worst economy since the Great Depression, the worst health crisis since 1918, flaring racial strife, violence in the streets and ominous tensions with China. For on Tuesday night, Republican voters in Iowa ousted King in a primary. They did so because Republican leaders finally disowned King last year after the latest of many outrageous provocations, and the Republican establishment lined up behind a challenger with King’s conservatism but without King’s bigotry.

This means there is at least a sliver of hope that Republicans have learned from their failure to deal similarly with Trump. The president now controls the party utterly, but the King episode suggests that after Trump is done shedding his virus, the party might have the antibodies to resist the next person who tries to infect it with totalitarian instincts and racist sentiments.

King made his name promoting “western civilization” and opposing bilingualism. He famously described “dreamers” — immigrants brought to the United States when they were children — having “calves the size of cantaloupes because they’re hauling 75 pounds of marijuana across the desert.” He supported racist leaders abroad, and he argued that “demographics are our destiny. We can’t restore our civilization with somebody else’s babies.” And on, and on.

His demagoguery gave him power. He got his proposal to end “birthright citizenship” considered in committee, and he defeated President George W. Bush’s hopes of immigration reform. Above all, he found an admirer in Donald Trump.

Trump saw the growing power of King’s politics with the tea party success in 2010, and in 2011 Trump praised King for “doing great work in the House.” For King’s reelection in 2014, Trump taped a robocall and went to Iowa for a fundraiser and endorsement news conference for “my friend” King.

There, they celebrated what King called their “common cause” — a “sovereign America” and “the rule of law.” Trump nodded along as King made insinuations about President Barack Obama giving special treatment to Africans and spoke of immigrants bringing in drugs, disease and gangs. Trump chimed in about Mexican drug lords “shooting our people and killing our people.”

Trump, testing a presidential run, returned for a King-hosted event in January 2015, at which he expressed his “great respect” for King, “a great guy” who “doesn’t get fair press.”

King, in turn, though initially endorsing Ted Cruz, campaigned with Trump in 2016. As late as October 2018, Trump, in Iowa, hailed King as “the world’s most conservative human being” and recalled: “I supported him long before I became a politician.”

And Trump has imitated him ever since. But while Republican officeholders tolerate Trump’s anti-immigrant bigotry, they had a higher standard for King. In early 2019, King told the New York Times: “White nationalist, white supremacist, Western civilization — how did that language become offensive?” Republican leaders stripped King of his committee assignments. The U.S. Chamber of Commerce and other pieces of the Republican establishment supported a King primary challenger. Officials blocked King from Air Force One when his protege flew to Iowa in mid-2019.

In a Facebook video early Wednesday morning, King described himself as the victim of “powerful” forces seeking “to push out the strongest voice for full-spectrum, constitutional, Christian conservatism. . . . What I regret is these tactics may get legs and be used against the next most effective, and the next and the next.”

King’s regret is my hope. It’s too late for Republicans to stop Trump. But as they survey the epic wreckage his presidency has caused, with their complicity, maybe they will find the courage to stop the racist demagogue in their midst the next time — if, after this catastrophe, there is a next time.

Watch the latest Opinions videos:

Read more: