President Donald Trump is not shy about expressing his frustrations with Attorney General Jeff Sessions, whose strict rule-of-law approach at the Department of Justice (DOJ) contrasts with the political role that President Barack Obama’s appointees played — and Trump expected.

But after November 6, Trump may have to thank Sessions for helping save Congress by mobilizing dormant conservatives in California around the “sanctuary state” fight.

California is, in many ways, the central political battlefield of the 2018 midterm elections. Democrats need to flip 24 Republican-held seats to regain the majority — and to put House Minority Leader Nancy Pelosi (D-CA) back in the Speaker’s chair, capping what would be one of the most remarkable political comebacks in American history. About half a dozen of those seats are in California districts that went for Hillary Clinton in the 2016 election.

Until recently, the momentum in California has been almost entirely on the Democrats’ side. In December, a poll showed that two-thirds of registered voters in the state disapproved of President Trump. Several leading California Republicans — including Foreign Affairs Committee chair Rep. Ed Royce and former House Oversight Committee chair Rep. Darrell Issa — announced their retirement.

Thanks in part to Sessions, things may be turning around.

The issue of “sanctuary” jurisdictions first came to the political fore in 2015, when 32-year-old Kate Steinle was killed in San Francisco by a seven-time felon and five-time deportee who somehow found himself in possession of a federal agent’s stolen gun.

At one point, the defendant — who was bizarrely acquitted of murder last year — told authorities he had sought refuge in San Francisco because he would be safe from federal law enforcement there.Then-candidate Trump seized on the issue, and championed the cause of other Americans who had been killed by illegal aliens.

After Trump won, California’s angry Democrats were determined to lead the so-called “Resistance” to his administration. The state government has sued Trump administration over two dozen times, and the state legislature upped the ante on immigration by passing “sanctuary” laws covering the entire State of California.

California Republicans did not react, at first, to the new “sanctuary state” laws. Instead, party leaders mobilized against a 12-cent-per-gallon gas tax Governor Jerry Brown enacted when he still had a two-thirds supermajority in the State Assembly. (Two Democrats later resigned over sexual misconduct claims.) Voters will be able to repeal the gas tax in November, and to recall one of the Democrats who voted for it. But the issue has never caught fire.

Enter Jeff Sessions.

When he came to Sacramento in early March, as the DOJ filed its lawsuit, politics seemed furthest from his mind — though he was as passionate as ever about the principles at stake.

“We believe that we cannot accept the kind of restrictions that California placed on federal law officers, and we believe that their actions exceeded the Constitution, and we will win in the courts eventually,” he told me in an early-morning interview.

Curiously, President Donald Trump did not comment publicly about the DOJ lawsuit. But the lawsuit provided sudden inspiration to California conservatives, who began demanding that local governments join in the Trump administration’s legal fight against the state.

Less than two weeks after Sessions came to Sacramento, the leaders of the Orange County city of Los Alamitos voted to defy California’s “sanctuary” laws and join the DOJ’s legal fight.

More than a dozen local governments in Orange and San Diego counties — including the counties themselves — soon joined the revolt against the “sanctuary state.”

And President Trump began to notice.

“There is a Revolution going on in California,” he tweeted last week. The next day, the president tweeted his thanks to San Diego County for its decision to support “our lawsuit against California’s illegal and unconstitutional ‘Sanctuary’ policies.”

The revolt against the “Resistance” has given California Republicans a reason to re-engage — and to hope. And the results have begun showing up in the polls.

For months, two Democrats — Lieutenant. Gov. Gavin Newsom and former Los Angeles mayor Antonio Villaraigosa — were first and second, respectively. Under California’s “jungle primary” rules, that meant they would face off in the general election in November, with Republicans shut out.

But in late March, Republican businessman John Cox surged past Villaraigosa into second place in one poll. A new poll this week also showed Cox in second — and State Assemblyman Travis Allen (R-Huntington Beach) in third. That poll also showed James Bradley, a hitherto unknown GOP candidate for U.S. Senate, surging into second place ahead of former State Senate President pro Tem Kevin de Léon (D-Los Angeles), the left-wing’s straggling favorite.

Those numbers could change before the June 5 primary, as Villaraigosa spends the money flowing into his campaign. But they show that immigration, not taxes, is the most important issue for the Republican base.

President Trump has caught on, and is stoking the fight with California at every opportunity.

Yet it was Sessions who started the revolt, whether he realized it or not. California — yes, California — could yet save the Republican Congress.

Joel B. Pollak is Senior Editor-at-Large at Breitbart News. He was named to Forward’s 50 “most influential” Jews in 2017. He is the co-author of How Trump Won: The Inside Story of a Revolution, which is available from Regnery. Follow him on Twitter at @joelpollak.