WASHINGTON — President Trump was walking through the Capitol corridors in February, en route to his State of the Union address, when he spied Mitch McConnell, the taciturn Senate majority leader, and rumbled over to deliver his signature verbal high-five.

“Mitch!” Mr. Trump said in a voice loud enough to be heard by a Republican aide pinned against a nearby wall. “I just saw you on Fox! You were totally great with Martha MacCallum!” he added, referring to a prespeech TV appearance in which he denounced the shutdown Mr. Trump initiated against his advice.

Mr. McConnell, of Kentucky, who grumbled in private about Mr. Trump’s decision, managed a laugh. The senator, allergic to public glad-handing, would have preferred a more substantive interaction. He had spent much of that week urging Mr. Trump, unsuccessfully, to abandon his plan to declare a national emergency at the border with Mexico to secure wall funds that Congress had denied him.

But the exchange captured the essence of an awkward, compulsory yet increasingly close working relationship between two men divided by temperament but Krazy Glued together by shared self-interest. Over the last six months, necessity has cast Mr. McConnell into a new role — as one of the president’s most important counselors, upping the pace and intensity of his one-on-one interactions. Nowadays, he speaks with Mr. Trump nearly every day and far more frequently during times of crisis, according to interviews with two dozen lawmakers, White House aides and administration officials.