On Monday, Mr. Trump insisted that he has a “fantastic relationship” with Republican members of the Senate, and he praised Mr. McConnell’s ability to shepherd the Republican agenda over what he called the nearly complete obstruction of Democrats in the Senate. The president also said that he will try to talk Mr. Bannon out of at least some plans to field hard-right primary candidates to challenge virtually every Senate Republican seeking re-election next year.
“The relationship is very good. We are fighting for the same thing,” Mr. Trump said during wide-ranging comments to reporters that also touched on immigration, health care, the opioid crisis, Cuba, military deaths and other topics. “We are fighting for lower taxes, big tax cuts, the biggest tax cuts in the history of our nation.”
White House officials described Monday’s lunch with Mr. McConnell as largely focused on efforts to cut taxes, and they said it ended with both men engaged and relaxed — a remarkable feat for two politicians whose personal styles could not be more different.
Mr. Trump has eagerly conducted his insurgent presidency in the glare of the cameras, antagonizing friends and foes alike and boasting of accomplishments large and small. Mr. McConnell, the definition of the Washington establishment, has always been a tight-lipped, back-room negotiator.
“In show-business parlance, Donald Trump is a show runner,” said Al Cross, a longtime Kentucky political journalist who has known Mr. McConnell for more than 30 years. “He’s all about the show — it’s all about getting good ratings for Donald Trump — and McConnell has never been about the show. He’s all about business.”
Mr. Trump mentioned in an aside at the news conference that he would soon outline an economic development plan, though he confessed that he had yet to tell Mr. McConnell about it.
Despite pledges by both men that they share the same agenda, any good will that may have once existed dissolved after the Senate twice failed to repeal the Affordable Care Act. After the first defeat in July, Mr. Trump tweeted in August: “Can you believe that Mitch McConnell, who has screamed Repeal & Replace for 7 years, couldn’t get it done.”
In another tweet in August, he said, “The only problem I have with Mitch McConnell is that, after hearing Repeal & Replace for 7 years, he failed!”
Privately, Mr. Trump has repeatedly denigrated Mr. McConnell, most recently unloading about the Senate Republican leader during a dinner this month with a group of about a dozen conservative movement leaders in the Blue Room of the White House. According to two people with knowledge of the president’s remarks, he called Mr. McConnell “a weak leader” and said that he remained befuddled at Mr. McConnell’s inability to wrangle the votes needed to repeal the Affordable Care Act.
For his part, aides to Mr. McConnell say that he has been deeply frustrated by Mr. Trump’s willingness to lash out, even as the Senate leader successfully guided the chamber to confirm Mr. Trump’s cabinet and judicial nominations, including the president’s choice of Neil M. Gorsuch to the Supreme Court.
Soon after Mr. Trump took office, Mr. McConnell told associates that the new president had no clear sense of where he stood on most core issues, and he predicted that steering Mr. Trump — and taking the lead on policy — would be relatively easy.
The two disagreed early on political strategy: Mr. McConnell wanted the president to nominate a Democratic senator in a conservative state for a cabinet post to help Republicans pick up a seat. Instead, Mr. Trump plucked Ryan Zinke, a Republican representative from Montana, for the Interior Department, ending Mr. McConnell’s hopes that Mr. Zinke, a popular former Navy SEAL, would challenge Montana’s Democratic senator, Jon Tester, in 2018.
In the months since, Mr. McConnell and his aides have watched Mr. Trump buck the Senate, both publicly and privately.
Mr. Trump has repeatedly hectored Mr. McConnell to scrap Senate rules that require most legislation to clear a 60-vote hurdle before final passage, a demand that the leader has resisted, in part, for fear of a return to Democratic control.
Mr. McConnell has also been taken aback by Mr. Bannon’s decision to start a political crusade against establishment Republicans in the Senate by recruiting candidates who could put at risk the party’s control. So far, Mr. Bannon has backed conservative challengers to Senators Jeff Flake of Arizona and Dean Heller of Nevada, and could formally back a challenger to Senator Roger Wicker of Mississippi.
Mr. McConnell said he was focused on keeping the Senate in Republican hands.
“The way you do that is not complicated,” Mr. McConnell said. “You have to nominate people who can actually win because winners make policy and losers go home.” He added a few moments later, “Our operating approach will be to support our incumbents.”
Mr. Trump said that Mr. Bannon “has been a friend of mine for a long time” and that his former strategist was doing “what Steve thinks is the right thing.”
But with Mr. McConnell standing next to him, the president hinted that he would not entirely support Mr. Bannon’s efforts to throw out of office Republicans who Mr. Bannon does not think are sufficiently supportive of Mr. Trump’s agenda.
“Some of the people that he may be looking at, I’m going to see if we talk him out of that,” the president said.
One person close to Mr. McConnell said Mr. McConnell has been very careful in his public comments about Mr. Trump in part because he did not want to put his wife, Elaine L. Chao — who serves as Mr. Trump’s secretary of transportation — in an awkward position with her boss.
Other advisers to Mr. McConnell said the two men both recognize that Republicans’ fate in 2018 hinges on whether Congress can pass the tax cuts that Mr. Trump is seeking.
“I feel like they are both under so much pressure to deliver — that’s what causes tension, real or imagined,” said Scott Jennings, a former adviser to Mr. McConnell who remains close to the majority leader. “They need to be able to jointly take something back to the voters next year to sell. I think winning on a major policy initiative like tax reform would allow for a further expansion of their relationship on politics.”
That level of cooperation — which has been so vital to the success of past presidents — was in danger of completely unraveling before Monday’s lunch. Over the objections of some of his advisers, the president had grown increasingly unwilling to set aside his insurgent tendencies to make Washington-style deals with Mr. McConnell.
Mr. Trump’s contempt grew even stronger after he backed Mr. McConnell’s preferred candidate last month in a special election in Alabama. That candidate — Senator Luther Strange — lost the election to Roy S. Moore, a defeat that Mr. Trump took personally.
And Mr. McConnell’s closest allies became increasingly aggrieved at the president’s treatment of the leader, especially because they view Mr. McConnell’s refusal to hold hearings for President Barack Obama’s Supreme Court nominee as critical to Mr. Trump’s election.
On Monday, both men sought to minimize the conflict between them in the interest of sending a signal of unity of purpose that could soothe the despair of allies who fear the feud imperils any hopes for the tax and budget legislation before the end of the year.
“We have the same agenda,” Mr. McConnell said.