Twelve days after Donald Trump’s election victory, the president-elect asked John Kelly to meet with him at the stately Trump National Golf Club in Bedminster, N.J., to discuss the roles of secretaries of State and Homeland Security.

It was a small gathering. Present was Reince Priebus, the Republican Party chair who later became White House chief of staff, a post that he resigned this week. Also attending was Steve Bannon, Trump’s chief strategist. Kelly, like other retired generals, impressed the president-elect, enough so that soon he’ll leave his post atop the Department of Homeland Security to replace Priebus in the West Wing.

That meeting last November launched what has become one of the president’s most important relationships within his beleaguered administration. He likes Kelly. He trusts Kelly. But what remains to be seen is whether Trump will listen to him as Kelly seeks to bring order to a White House beset by chaos.

After it was announced that Priebus would be leaving, a friend of the Homeland Security secretary told The Washington Post that Kelly, a tough talking Bostonian who spent 45 years in the Marines, is ideally suited to confront the challenges he’ll face.

“He knows how to do this: with common sense and good leadership,” said Kelly’s longtime friend, who spoke on the condition of anonymity to offer frank opinions. “He won’t suffer idiots and fools.”

But Kelly did not gel with the previous administration, and his military career ended on a sour note in January 2016 after he repeatedly clashed with the Obama White House.

Officials there had grown tired of the four-star general speaking off message — about the president’s plan to shut down the prison in Guantanamo Bay, Cuba, about the perceived vulnerability of America’s borders, about the threat posed to American interests by any number of terrorist organizations. Their relationship had become so strained that in the weeks before he retired, multiple administration officials went to the media and accused Kelly and other military leaders of endeavoring to undermine the Guantánamo closure plan.

At Bedminster, Trump and Kelly discussed the general’s diplomatic experience and the security concerns about which both men remain deeply passionate.

His final job in the military, as head of U.S. Southern Command in Miami, gave Kelly deep insight into the criminal networks ravaging South America, Central America and the Caribbean, and their illicit trafficking pipeline — for drugs, guns and people — running north through Mexico and into the United States. He has long argued that transnational organized crime is among the greatest threats to U.S. national security.

As Kelly moves to the West Wing, he’ll likely move quickly to confront the “reality television show that runs on a raucous mix of drama, machismo and suspicion,” as The Post’s White House team characterized it Thursday. A big piece of that will be addressing leaks and the president’s portrayal in the media.

“There’s a way to handle it,” Kelly’s friend said. “Simply go dark and do not engage.”