The two men, whose friendship was cemented during the two and a half months in which Mr. Bannon helped rescue Mr. Trump’s presidential campaign, reinforced each other’s rough-around-the-edges tendencies. Both could be gratuitously foul-mouthed, viciously cutting to their enemies and unapologetically politically incorrect. “Dude, he’s Archie Bunker,” Mr. Bannon would say with fondness when talking about Mr. Trump.

Mr. Bannon fed Mr. Trump’s paranoid streak and shared the president’s penchant for believing in conspiracies. He viewed not just intelligence agencies but most of government as stocked with a devious bureaucratic underbelly, the “deep state.” Mr. Trump, who has never worked in government, eagerly adopted that view.

Mr. Bannon was notorious for maintaining his own, shadowy presence within the White House. He would frequently skip meetings where policy was discussed, injecting his views into the process in other ways, according to two administration officials. He did not use a computer, preferring to have paper printed and handed to his assistant to stay outside the formal decision-making process.

Mr. Bannon favored a culture similar to the one Mr. Trump brought with him from the business world to the White House — a flat structure with blurred lines of responsibility and competing power centers. And early on Mr. Bannon benefited from that structure, sitting at the top, free to slip unvetted materials to the president without a gatekeeper to get past.

“Theoretically, a more coherent staff should produce a more coherent policy,” said David Axelrod, who was President Barack Obama’s senior adviser and the person in a comparable role to Mr. Bannon in the White House. “But that presupposes a president who embraces the process and the policy.”

With little process to speak of, tensions over policy swelled. Ideological differences devolved into caustic personality clashes. Perhaps nowhere was the mutual disgust thicker than between Mr. Bannon and Mr. Trump’s daughter and son-in-law.

Mr. Bannon openly complained to White House colleagues that he resented how Ms. Trump would try to undo some of the major policy initiatives that he and Mr. Trump agreed were important to the president’s economic nationalist agenda, like withdrawing from the Paris climate accords. In this sense, he was relieved when Mr. Kelly took over and put in place a structure that kept other aides from freelancing.