Roger Ailes understood the appeal Mr. Trump had for Fox viewers. He didn’t foresee how together they would redefine the limits of political discourse.When Roger Ailes ran CNBC in the mid-1990s, he gave himself a talk show called “Straight Forward.” It long ago vanished into the void of canceled cable programs and never received much attention after the network boss moved on to produce more provocative and polarizing content as chairman of Fox News. But “Straight Forward” was a fascinating window into what kind of people Mr. Ailes considered stars.Donald Trump was one of them. In late 1995, Mr. Ailes invited Mr. Trump, then a 49-year-old developer of condos and casinos, on the show and sounded a bit star-struck as he asked his guest to explain how a Manhattan multimillionaire could be so popular with blue-collar Americans.“The guy on the street, the cabdrivers, the guys working on the road crews go, ‘Hey, Donald! How’s it going?’” Mr. Ailes observed while the two men sat in front of a wood-paneled set piece that gave the studio the appearance of an elegant den in an Upper East Side apartment. “It’s almost like they feel very comfortable with you, like you’re one of them. And I’ve never quite figured out how you bridge that.”Mr. Trump answered by flipping his host’s assertion around. It was because of who hated him: other people with money. “The people that don’t like me are the rich people. It’s a funny thing. They can’t stand me,” Mr. Trump said, adding, “I sort of love it.”What Mr. Ailes sensed about Mr. Trump’s popularity with middle- and working-class Americans in the 1990s would stay with him, because he identified with it. “A lot of what we do at Fox is blue collar stuff,” he said in 2011.His understanding of those dynamics helped shape the coverage he directed for decades and led to an embrace of grievance-oriented political rhetoric that the Republican Party, and a further fragmented right-wing media landscape, is grappling with as it looks toward elections this fall and the possibility of Mr. Trump returning to politics.Roger Ailes interviewing Mr. Trump in 1995. “The people that don’t like me are the rich people,” Mr. Trump said.CNBCMr. Ailes was eventually ousted from Fox after several women at the network came forward to say he had sexually harassed them. But before that, his intuition about what audiences wanted — and what advertisers would pay for — helped Fox News smash ratings records for cable news. He could rouse the viewer’s patriotic impulses, mine their darkest fears and confirm their wildest delusions. Its coverage of then-Senator Barack Obama’s presidential campaign, often laced with baseless speculation about his past, helped propel the network in 2008 to the highest ratings it had ever recorded in its 12 years of existence. Mr. Ailes earned $19 million that year.As he looked to assemble a dynamic cast of right-wing media stars to channel the rage and resentment of the budding Tea Party insurgency, Mr. Ailes’s instincts pushed Fox News ratings even higher.Three personalities he put on the air at Fox during that period stood out for the way they gave voice to a particular kind of American grievance. There was Glenn Beck, whose show debuted the day before the Obama inauguration in 2009. There was also Sarah Palin, who joined as a paid contributor earning $1 million a year in 2010.And of course there was Donald Trump. He was “relatable rich,” Mr. Ailes told his staff, betting that viewers would see something aspirational in him, when he decided to give Mr. Trump a weekly morning slot in early 2011.But it was what Mr. Ailes did not see about Mr. Trump — how his popularity was a double-edged sword — that led him to the same flawed assumption that the leaders of the Republican Party would eventually make. What neither they nor Mr. Ailes considered fully as they opened their arms to these insurgent forces was what would happen if encouraging and empowering them meant redefining the limits of acceptable political discourse, dropping the bar ever lower, and then discovering that they were helpless to reel it back in.That’s how Fox News landed in a once-unthinkable position behind CNN and MSNBC in the ratings in the weeks after Election Day in 2020, losing viewers to outlets like Newsmax and One America News eager to revel in — and profit from — the kind of misinformation that Fox rejected when it told its audience the truth about Mr. Trump’s defeat in Arizona.In reporting this book on the Republican Party, I spoke with the former president several times, and we discussed media coverage that debunked his unfounded claims about the 2020 election.“A lot of people don’t want that,” Mr. Trump told me in an interview about a month after President Biden’s inauguration, referring to critical — if accurate — news reports about his behavior. “They don’t want to hear negativity toward me.”Trump as a manageable riskAt his core, Mr. Ailes was two things that made him think someone like Mr. Trump was a manageable risk: deeply motivated by growing the size of the Fox audience and the attendant profits that would fatten his annual bonus; and an establishment Republican who, as G.O.P. strategist, had helped elect Nixon, Reagan and George H.W. Bush.He was no different from the transactionally minded Republican leaders in Congress who looked at the energized group of voters in the Tea Party and thought: This is going to be good for business. Christopher Ruddy, the chief executive of Newsmax, recalled speaking with Mr. Ailes about the budding new political movement on the right — which would be good for both men’s bottom lines — and said that while Mr. Ailes liked the movement’s use of patriotic language and its rebellious spirit, he ultimately “saw them as a convenient grass-roots group.”Mr. Trump, Mr. Beck and Ms. Palin — three new Fox stars — initially delivered what Mr. Ailes was looking for: compelling television, good ratings and content viewers could find nowhere else. All three also ended up growing into big enough political celebrities in their own right — one more popular and entitled than the next — that Mr. Ailes eventually lost his ability to control them. (Through representatives, Mr. Beck and Ms. Palin declined to be interviewed.)One outburst from Mr. Beck in the summer of 2009 in particular demonstrated the extent to which norms were being stretched. That July, the raw, racialized anti-Obama anger of Tea Party sympathizers collided head-on with the country’s fraught history of systemic racial discrimination in Cambridge, Mass., when the noted Black scholar and Harvard professor Henry Louis Gates Jr. was arrested at his home after a neighbor assumed he was a burglar and called the police. The president defended Mr. Gates and criticized the police who had “acted stupidly,” in his view.Glenn Beck, here rehearsing his Fox News Channel show in 2009, was a Fox star but eventually fell out of Mr. Ailes’s favor.Nicholas Roberts for The New York TimesMr. Beck responded during an interview on “Fox & Friends,” saying that Mr. Obama had revealed his “deep-seated hatred for white people.” Then he added, matter of factly, “This guy is, I believe, a racist.” When a public outcry ensued, the response from the network was to defend their host. Bill Shine, head of programming, released a statement that called Mr. Beck’s comment a “personal opinion” and not reflective of the network’s views over all. “And as with all commentators in the cable news arena, he is given the freedom to express his opinions,” Mr. Shine added.The significance was hard to overstate. One of the biggest stars on the most-watched cable news network in the country said the country’s first Black president hated white people. And the response from Fox News was to say it was all perfectly defensible.But Mr. Beck would be out at Fox soon enough, as Mr. Ailes became convinced antics like these were too much of a distraction. According to a former senior on-air personality, Mr. Ailes told other people at the network that Mr. Beck was “insane” and had complained to him about various physical ailments that seemed fake, including fretting once that he might be going blind. The network announced Mr. Beck’s departure in the spring of 2011.A Fox News snubThe network’s relationship with another one of its stars was also changing: Mr. Ailes expressed concern about some of Ms. Palin’s public statements, including engagement with critics.Ms. Palin appeared to have reservations of her own. And the tension with Mr. Ailes, which was more nuanced than known publicly, would help open the door at the network for Mr. Trump.She told people close to her at the time that Mr. Ailes made her uncomfortable, especially the way he commented on her looks. “He’s always telling me to eat more cheeseburgers,” she told one member of her staff.Once, after a private meeting in Mr. Ailes’s office at the network’s headquarters in Midtown Manhattan in 2010, she came out looking white as a ghost.Sarah Palin on “The Sean Hannity Show” during the Iowa State Fair in Des Moines in 2011.Chip Somodevilla/Getty ImagesMr. Ailes’s assistant had asked that the aides and family members traveling with her wait outside so the two of them could meet alone. And when she emerged, according to the former staff member who was there, she said, “I’m never meeting with him alone again.”She was the biggest star in Republican politics at the time. The former governor of Alaska and 2008 Republican vice-presidential nominee had come as close as anyone ever had to leading the leaderless Tea Party movement. And even without Fox, the media was tracking her every move.Over Memorial Day weekend in 2011, a caravan of journalists chased her up the East Coast during a six-day trip from Washington to New Hampshire, believing she might use the occasion to announce that she would run against Mr. Obama. The trip also included a dinnertime stop at Trump Tower, where she and its most famous resident stepped out in front of the paparazzi on their way to get pizza.She wouldn’t reveal her intentions until later that year, in October. And when she did, she broke the news on Mark Levin’s radio show — not on Fox News. It was a slight that infuriated Mr. Ailes, who had been paying her $1 million a year with the expectation that it would pay off with the buzz and big ratings that kind of announcement could generate.The Void Trump FilledThere were signs at the time that Mr. Trump was starting to fill the void in Fox’s coverage — and in conservative politics — that would exist without Ms. Palin center stage. He had been getting a considerable amount of coverage from the network lately for his fixation on wild rumors about Mr. Obama’s background.One interview in March 2011 on “Fox & Friends” — the show known inside the network to be such a close reflection of Mr. Ailes’s favorite story lines that staff called it “Roger’s daybook” — was typical of how Mr. Trump used his media platform to endear himself to the hard right. He spent an entire segment that morning talking about ways that the president could be lying about being born in the United States. “It’s turning out to be a very big deal because people now are calling me from all over saying, ‘Please don’t give up on this issue,’” Mr. Trump boasted.Three days after that interview, the network announced a new segment on “Fox & Friends”: “Mondays With Trump.” A promo teased that it would be “Bold, brash and never bashful.” And it was on “Fox & Friends” where Mr. Trump appeared after his pizza outing with Ms. Palin in the spring, talking up his prospects as a contender for the White House over hers. Mr. Trump and Mr. Ailes were, at first, seemingly well matched.Though he had financial motivations for promoting sensational but misleading stories, Mr. Ailes also seemed to be a true believer in some of the darkest and most bizarre political conspiracy theories.In 2013, Mr. Obama himself raised the issue with Michael Clemente, the Fox News executive vice president for news, asking him at the White House Correspondents’ Dinner whether Mr. Ailes was fully bought-in on the conspiracies over the president’s birthplace. “Does Roger really believe this stuff?” Mr. Obama asked. Mr. Clemente answered, “He does.”The network boss and the celebrity developer also shared a dim view of the man who would win the 2012 Republican nomination, Mitt Romney. On election night, Mr. Ailes had already left the office by the time his network’s decision desk called the race for the president. Shortly after the election, he visited Mr. Romney at the Essex House, a posh hotel on Central Park South, to pay his respects. He also offered the candidate his unvarnished paranoia about the outcome.The Democrats had pulled a fast one, Mr. Ailes said, just as they always do. “They make promises they can’t keep. And they’re dirty. They cheat,” he said.Mr. Ailes, with his wife, Elizabeth, leaving the News Corp building in 2016.Drew Angerer/Getty ImagesMr. Ailes did not live to see Mr. Trump’s second, unsuccessful presidential campaign. A hemophiliac, he died after a bad fall in 2017. As confident as he was in his instincts that Mr. Trump would deliver good ratings, he wasn’t oblivious to the downside of emboldening him. At one point in 2016, he complained to a colleague, the former Fox News chief legal analyst Andrew Napolitano, that he dreaded hearing from Mr. Trump.“I hate it when he calls me. He talks to me like I talk to you. He cuts me off. He doesn’t let me finish my sentences. He constantly interrupts me,” the network chief grumbled to his subordinate, Mr. Napolitano recalled.But there is no doubt that in his chase for ratings and revenue, Mr. Ailes ultimately made his network the subordinate in its relationship with Mr. Trump. And for all his paranoia, Mr. Ailes failed to see how that might happen.Mr. Trump is still embittered by Fox’s decision on the night of the election to project that he had lost Arizona, and therefore most likely the White House. In an interview late last summer, he boasted about their ratings slide. “They’re doing poorly now, which is nice to watch,” he said.Fox News lost its crown as the most-watched cable news outlet in the weeks after the 2020 election, but it quickly regained it. It remains dominant today. Questions about its future in a Republican political environment still dominated by the former president abound. Will Mr. Trump grow irritated enough with the network to lash out and urge his followers to change the channel, tanking ratings again? Will its decision desk still feel empowered to make bold calls like the Arizona one after facing such an intense backlash?“Roger wasn’t the easiest guy to deal with,” Mr. Trump said in our interview, nodding to the rupture in their relationship toward the end. “But he was great at what he did. And he built a behemoth.”Then he offered a warning: “And that behemoth can evaporate very quickly if they’re not careful.”Jeremy W. Peters, a reporter for The New York Times, is the author of “Insurgency: How Republicans Lost Their Party and Got Everything They Ever Wanted,” from which this article is adapted. He is also an MSNBC contributor. More