Sen. Lindsey Graham, R-S.C., may have finally cracked the code for dealing with President Trump, whose erratic leadership style often mystifies Washington.

“You could be as dark as charcoal and lily white, it doesn't matter as long as you're nice to him," he said in an interview on CNN. "You could be the pope and criticize him, it doesn't matter, he'll go after the pope. You could be Putin and say nice things, and he'll like you."

Graham meant this as a defense of the president against charges of racism. But it could also explain his own about-face on Trump, a man the senator called a “jackass” and a “kook” when the two were rivals for the 2016 Republican presidential nomination.

“If we nominate Trump,” Graham predicted at the time, “we will get destroyed … and we will deserve it.”

Instead Trump won states, however narrowly, that had eluded Republicans since Ronald Reagan was president on his way to the White House. Since then, Graham’s approach to Trump has reflected the old saying about catching more flies with honey than vinegar — and the South Carolinian is not alone.

Early one morning last week, it looked as if Sen. Rand Paul, R-Ky., had won a key convert on surveillance. Mere hours before the House was set to vote on reauthorization of Section 702 of the Foreign Intelligence Surveillance Act, which Paul and a bipartisan group of civil libertarians wanted badly to reform, the mercurial Trump tweeted.

“This is the act that may have been used, with the help of the discredited and phony Dossier, to so badly surveil and abuse the Trump Campaign by the previous administration and others?” the president asked, signaling opposition and potentially throwing last-minute whip counts into disarray.

Fox News analyst Andrew Napolitano, a Paul family ally, had made a similar observation about FISA on a broadcast the president may have watched. Paul, a polar opposite of Graham on foreign policy and civil liberties, had been trying to get Republicans sensitive to the president’s concerns about unproven Trump Tower wiretapping to apply that to the broader surveillance debate, even as he exhorted Democrats to deny such powers to a commander in chief they claim to “resist.”

“This was a witch hunt that began with the Obama administration,” Paul maintained, referring to former national security adviser Susan Rice’s reported requests for “unmasking” Trump campaign officials, on MSNBC’s “Morning Joe” last year. “Sour grapes on the way out the door. They were going to use the intelligence apparatus to attack Trump and I think they did.”

“The most useful people to spy on are in a position of power,” said a policy analyst who works on surveillance issues but isn’t authorized to speak publicly about partisan politics. “It’s not just Trump.”

Trump and Paul had sparred on the campaign trail too. While both candidates for the Republican nomination, Paul described Trump as a “delusional narcissist and orange-faced windbag.” Trump countered with barbs about Paul’s appearance and qualifications to appear in presidential debates. Trump had also called Graham an “idiot” and a “lightweight.” The two reconciled after the election, however.

As was the case with Trump’s tweets about the Children’s Health Insurance Program’s handling in a continuing resolution on Thursday, the unexpected FISA reversal was swiftly adjusted after conversations with House Speaker Paul Ryan, R-Wis., and other officials. The reauthorized legislation is on its way to the president’s desk.

But Trump is persuadable and some former Republican critics, including vanquished primary opponents like Paul and Graham, appear to have decided the better strategy is to try and reach him.

“I can say that Sen. Rand Paul will try to persuade anyone who will listen and will use all tools available to him to bring change to this problematic piece of legislation which deprives innocent Americans of their right to privacy,” said a source close to the Kentucky lawmaker.

Like Graham, Paul is a golfing buddy of the president’s. But just as they are countervailing influences against each other, they aren’t alone in trying to win Trump’s ear.

Graham in recent days has sounded disappointed that Trump has moved away from him on immigration. Sens. Tom Cotton, R-Ark., and David Perdue, R-Ga., have been trying to keep Trump faithful to the more restrictionist positions he took during the campaign. Both of those lawmakers defended him more forcefully from the “shithole” firestorm than did Graham.

Perdue has become one of Trump’s closest allies on Capitol Hill. Meanwhile, the president has shown a willingness to mend fences even with Sen. Bob Corker, R-Tenn. With everyone trying it, there might be a limit to how much influence any single lawmaker can have.

It beats the alternative, however. “Lindsey used to be a great enemy of mine, and now he's a great friend of mine,” Trump acknowledged after a White House meeting earlier this month. “I really like Lindsey. Can you believe that? I never thought I'd say that, but I do like him a lot.”