In many ways, this is the election that Fox News built. For years, the network has stoked the fires of right-wing resentment of Hillary Clinton, Barack Obama, and "liberal elites" — while simultaneously giving prominence and credibility to the Tea Party, to "issues" like birtherism and the New Black Panthers, and to those darlings of the anti-establishment right Glenn Beck and Sarah Palin. Its coverage foreshadowed much of what makes the Trump campaign distinctive — the bluster, the conspiratorial mindset, the Obama hatred — even if the network was, at first, resistant to embracing the real estate mogul.

A casual observer might think Donald Trump’s candidacy would be a triumphant moment for Fox News. Yet the network was in turmoil even before its chair and CEO, Roger Ailes, left the network amid sexual harassment allegations — which he did on the first day of the 2016 Republican convention.

We shouldn’t understate the importance of Ailes’s departure. For 20 years, the television producer and political consultant had provided the guiding vision for the network, micromanaging everything from the onscreen artwork to the state of the studio hallways (scuff-marked and utilitarian, to keep folks from being lulled into complacency by posh surroundings). It was fair to wonder, with Ailes out, what would become of the network he had built.

But the loss of Ailes may turn out to be a side story in the long run. That’s because the disruption of Fox by right-wing media rivals had begun well before Ailes’s exit. By the time the harassment charges surfaced, the conservative GOP built in the late 1990s was in disarray, and Fox News, the party’s house organ, was facing its own insurgency.

Not only were insiders divided over what they had spawned – Trumpism – but the network was feeling the heat from new outlets, including Breitbart, that saw Fox News as the establishment that needed toppling.

The network was a conservative dream made real

To understand Fox News today, you have to place it in the context of the growth of right-wing media over the past half-century. When the network went live 20 years ago, it was the fulfillment of a decades-long dream for conservatives, who had been eyeing television for decades, believing it was key to changing both the political and media landscape.

But TV continually confounded them. In the 1960s, a few conservative radio programs, like the Manion Forum and The Dan Smoot Report – hosted by Clarence Manion and Dan Smoot — had complementary television shows, but they reached tiny audiences and were short-lived.

Why was television so hard to crack? Bias was the pet theory of many conservatives, including D.B. Lewis, a dog food manufacturer who sponsored the Manion and Smoot shows in California. He believed the main barrier to conservative programming was the networks’ unwillingness to syndicate controversial right-wing shows. There was something to the idea — or, at least, local station owners believed the same thing. They refused to sell Lewis time for Smoot and Manion’s programs, fearing they would alienate their established audiences and drive away advertisers.

The right’s frustration over this blackout led to the first attempt to establish a conservative television network. The project, undertaken in 1965, was the brainchild of David Dye, a businessman from Lubbock, Texas. Believing that all media was "dominated by liberal and internationalist managements," Dye founded Medias Unlimited, whose main purpose was to organize conservative shareholders to take over a major network.

The Dye plan was a long shot, to put it mildly. Dye bought 200 shares of CBS, then gave himself the goal of getting 1,000 others to do the same. Each of those 1,000 was instructed to recruit 20 more share buyers in order for conservatives to have a controlling interest in CBS. CBS did gain 13,000 new shareholders in the first half of 1965 — "We are confident that most of these are ‘our’ people," Dye told the radio host Paul Harvey — but conservatives never mustered enough shares to enact Dye’s plan. The dream of a conservative network would have to wait.

While Dye wanted to seize control of a network, another media entrepreneur was more narrowly targeting the world of TV news. Roger Ailes, who had built a career in entertainment television — notably as executive producer of The Mike Douglas Show — latched, remora-like, onto the 1968 Nixon campaign. He attempted, with middling success, to turn the reticent Nixon into the first entertainer-in-chief. He couldn’t wangle his way into a position within the administration, but he did convince the Nixon team to use him as a consultant on media matters.

That’s how Ailes came to weigh in on a 1970 White House memo called "A Plan for Putting the GOP in the News." The project proposed, not a network, exactly, but a system for getting "pro-Administration" video packages into the hands of local news stations. Ailes offered to run the project, which was to be called the Capitol News Service.

Why had his interest shifted from entertainment to news? Opportunism, most likely. A year earlier, Vice President Spiro Agnew had fired the opening shot in a war against the press, challenging the practice of "instant analysis," where network anchors and commentators dissected press conferences and presidential announcements as soon as they concluded. The practice, while tame compared with today’s gabfests, enraged President Richard Nixon, who saw it as one more way the press was attempting to undermine his presidential authority; he unleashed Agnew on the "closed fraternity of privileged men, elected by no one" who managed the nightly news.

The Capitol News Service might have been just the thing to address this problem, despite the whiff of propaganda it emitted, but it never quite got off the ground. A year later the White House severed ties with Ailes, who temporarily retreated back into entertainment — theater this time.

His reentry point, in 1974, was Television News Incorporated, TVN. Dreamed up by former ABC exec Robert Pauley and funded by conservative millionaire Joseph Coors, TVN aimed to be a right-wing news service that largely concealed its ideological bent. Unable to turn a profit, TVN shut down one year after Ailes was brought in to whip it into shape. But it was there that Ailes got a taste for creating conservative news, one he would satisfy 20 years later, when technology — and politics — was more in line with his goals.

Fusing the conservative movement and the Republican Party — in one network

There were many things that made 1996 an auspicious year for the launch of Fox News. Cable had come of age, bursting open the bandwidth from a handful of channels to dozens. Innovations in digital cable and satellite were on the cusp of increasing that capacity exponentially, while that year’s Telecommunications Act began the deregulation of the entire industry.

Just as important, the Republican Party had made a sharp turn to the right. By the mid-1990s, it was possible to talk about the GOP and the conservative movement as though they were the same thing, something that wouldn’t have made much sense in earlier decades. The merger of the movement and party meant Fox News would sit at the confluence of two streams: conservative media and Republican politics.

Since the 1950s, conservative media activists had been training the grassroots right to reject mainstream media sources and seek out conservative voices. But not necessarily Republican voices. It’s true that from 1964 on, conservative media personalities largely supported the Republican Party. Quite often, however, they were willing to break from it.

There were many on the right who refused to support Nixon in 1968, but by 1972 the entirety of the conservative movement was in revolt, thanks to Nixon’s decision to open relations with communist China. And 1976 was a boom year for right-wing third-party schemes. Throughout the 1960s and '70s, conservatives flirted with the GOP but weren’t quite ready to wed it.

Ailes, however, was all in; from the start, his interest was in advancing the Republican Party. After TVN failed, Ailes wandered through a number of Republican administrations. Then in 1992 he crossed the politics-media barrier one last time. With talk radio host Rush Limbaugh’s star rising and George H.W. Bush’s reelection campaign flailing, Ailes swapped Bush for Rush, becoming executive producer of Limbaugh’s new television show. Before he did, however, he used the radio star to try to rescue the embattled president. In the summer of 1992, Ailes and Limbaugh were Bush’s guests at the White House, a move that led to far more favorable coverage on Rush’s program.

Ailes backed the right horse. Bush lost, but Rush kept accruing power. Over the next few years, he was hailed as the voice of the Republican revolution, an honorary member of the GOP. The merger of conservatism and Republicanism was complete. It was in this political setting that Ailes, partnered with Rupert Murdoch, launched his new cable venture. Murdoch provided the money, Ailes the vision, and on October 7, 1996, the Fox News Channel went live.

That the first conservative network was a news network mattered. The denizens of talk radio seldom positioned themselves as the opposite of journalists: They were brash, opinionated, ideological. Fox News blended that talk radio aggressiveness with a hard news persona —with the sort of pro-Republican reporting that Ailes sought while working for Nixon.

Under the winking tagline "Fair and Balanced," Ailes and Murdoch created a new media model more reminiscent of 19th-century party papers than 20th-century journalism. Those papers had delivered the news with a partisan spin, and sometimes even had overt ties to parties. They functioned as the campaign surrogates of the day, before they were crowded out first by the penny press and then by the rise of objective reporting.

What Fox News had that those papers didn’t was a sharp-eyed auteur with an entertainment background. Ailes’s vision informed most decisions at the network, where politics blended with entertainment, just as news mixed with opinion.

And it wasn’t just the glossy sets and flashy chyrons. Women hired as on-air talent had to meet his standards for beauty, which gave rise to the "Fox News blonde" — blonde being Ailes’s preference. He installed glass-topped desks and a leg cam to make sure audiences got an eyeful of the women’s legs, always on display thanks to requisite knee-length dresses. He passed it off as a part of entertaining audiences; in 2016, as more and more accusers came forward, it started to look like a pathology.

Fox News was in a new and dangerous position. It had become part of the conservative establishment — just as the grassroots right was turning on that establishment.

But that was after the fall. At the time, it was a winning formula. By 2001, the station was in a prime position, with the best ratings in cable news and the best-case scenario in Washington: a Republican president and Congress.

The Bush years were good for Fox News, which had become the go-to channel of the GOP right. Nor was Bush’s defeat much of a problem. Just as Limbaugh had thrived in the Clinton years, so too was Fox set to stay on top during the Obama years. The channel became the media arm of the government in exile. The Tea Party may have been born on CNBC – with a rant by correspondent Rick Santelli — but it was raised at the News Corp. building, where Fox News personalities nurtured the movement, appearing at rallies and offering wall-to-wall coverage of the raucous 2009 "town hall" meetings.

With the White House in Democratic hands, Fox News took on a new role: an incubator for presidential hopefuls. Sarah Palin transitioned easily from the campaign trail to the news studio. After she resigned as governor, her spot at Fox scored her a million-dollar paycheck and a chance to keep her face front and center.

Nor was she the only one using the tactic. Mike Huckabee, Newt Gingrich, Rick Santorum: These out-of-office 2012 hopefuls all had contracts with Fox in the runup to the primaries. And if their membership in the pundit class led them to say impolitic things from time to time — well, maybe the base, filled with Fox News watchers, had developed a taste for the impolitic.

They weren’t the only ones eyeing 2012. With a wide-open primary, Ailes wanted to be kingmaker. As Gabe Sherman recounts in The Loudest Voice in the Room, Ailes told Fox executives, "We’re making a lot of money — that’s fine. But I want to elect the next president." And with GOP presidential hopefuls scrambling to reach Fox’s audience, it seemed like he would get his wish. Home of the Tea Party as well as the GOP’s presidential bench, Fox had achieved Ailes’s vision. The Republican Party had its media voice, and conservatives had their network.

The unraveling of Fox News

The trouble began, counterintuitively enough, with the Tea Party. Fox News had blanketed the airwaves with early coverage of the movement, and the Tea Party’s figureheads, Glenn Beck and Sarah Palin, were stars at the network. Beck in particular was a ratings juggernaut. But Palin and Beck were independent operators who increasingly pushed back against Ailes’s advice; Ailes was reportedly uncomfortable with Beck’s gold-bug politics and apocalyptic worldview. Moreover, untested Tea Party candidates seemed to be hurting the GOP as much as helping it.

Reticence toward the Tea Party began to open up an establishment-grassroots divide — with Fox News on the establishment side. In 2012, both Gingrich and Santorum took public swipes at the network, arguing it was biased toward establishment favorite Mitt Romney. Shortly thereafter, with their interests increasingly diverging from those of Fox, Palin and Beck both parted ways with the network. Soon, both started new media enterprises of their own.

More trouble came in 2013. As Marco Rubio began to push for immigration reform, so too did a number of Fox News personalities, including Bill O’Reilly and Sean Hannity. For conservatives opposed to reform, this seemed like too much of a coincidence, and they were right. In early 2016 the New York Times broke the story that Rubio and Chuck Schumer had met with Ailes and Murdoch in January 2013 to get the channel to back reform. The network executives agreed, not anticipating the scale of the backlash against the Senate reform efforts.

Fox News was in a new and dangerous position. It had become part of the conservative establishment — just as the grassroots right was turning on that establishment.

Other threats appeared as well, driven by new technologies. The conservative web exploded during the 2000s. New digital cable and internet news networks popped up: Glenn Beck’s the Blaze (which is now struggling), the One America News Network, Newsmax TV. They had a brasher style and wore their ideology even more openly than Fox. Fox News might interview Peter Schweizer, author of Clinton Cash. One America News aired the documentary based on his book.

There was also a heavier dose of conspiracy on the new networks. Newsmax TV has aired "Roswell Top Secret," and it features Dick Morris, author of the 2012 book Here Comes the Black Helicopters!. Fox was no longer the only place for the grassroots right to turn, nor the only channel where would-be conservative personalities could go to make a name for themselves.

But the conservative media world didn’t just expand. It fragmented. There was no longer any reason to stick with conservative media sources that didn’t quite match your politics. If National Review was insufficiently anti-Muslim, there was Pamela Geller’s blog Atlas Shrugs. If the neoconservative Weekly Standard was too hawkish, there was the relatively non-interventionist American Conservative. And if Fox News shows were pushing immigration reform, there was Breitbart.

Breitbart News started off as the Fox News of the internet: a news-ish site guided by conservative politics. That changed when, following the death of Andrew Breitbart, Stephen Bannon took over. Bannon’s politics were right-wing, but not strictly conservative. They were decidedly more populist, with far more tolerance for the political fringes.

Bannon brought aboard Milo Yiannopoulus, the spokesperson of the alt-right. Yiannopoulos described himself and the alt-right as free speech fundamentalists, whose willingness to offend was an expression of their freedom. But that language provided cover for anti-Semites, white nationalists, misogynists, and other fringe groups long banished from American politics. They now have a home on Breitbart.

Breitbart now rejects the label of conservative, opting instead to call itself populist-nationalist. The site calls for conservatives to give up their ideological commitments to free trade and become populists on immigration, trade, and foreign policy — in other words, to transform from the base of the party of Reagan to that of the party of Trump.

Is Bannon the new Ailes? Both men moved over to the Trump campaign from their respective organizations — Bannon as campaign manager, Ailes as a consultant (now reportedly at odds with his client, who is apparently less coachable than Nixon). Both come from entertainment backgrounds. But Bannon is the younger man, and seems temperamentally to be more in touch with Trump and his more avid supporters. And unlike Ailes, he’s no acolyte of the Republican Party. Unless the next Republican nominee is a Trump-like candidate, Bannon may want to challenge the GOP rather than shore it up.

The fragmenting of the right-wing media mirrors the fracturing of the American right. The conservatism forged in the postwar era still exists, but it now shares space with populist nationalists, unreconstructed libertarians, and the alt-right. The Republican Party has not yet figured out how to accommodate this contentious coalition of interests.

Except for a few establishment types and a sprinkling of foreign policy experts, most of these factions are doing their best to give an impression of unity, but that will fall away after November 8 – especially if Trump loses. Party leaders need the grassroots right, the source of the party’s energy. And they have no real way to purge the Trumpists from their ranks.

But how do these factions square their incompatible preferences? How do free traders coexist with protectionists? How do reformicons, keen to build a broader, more inclusive party, make peace with the decidedly non-inclusive supporters of the Trump campaign? Coalition building is not out of the question, but civil war seems far more likely.

And Fox News? As it marks its 20th anniversary, it too is in flux. Without Ailes at the helm, it may be easier for the organization to adapt to this new American right. Sean Hannity, a Trump booster from the start, could be the entering wedge, along with Eric Bolling, Trump’s defender on the panel show The Five.

Or, equally likely, it will be a casualty of the anti-establishment war, a sacrifice to the gods of populism. Either way, it is unlikely to retain its singular place in the conservative media landscape. Having benefited from the labors of the first generation of conservative media, Fox News is well on its way to being eclipsed by the third.

Nicole Hemmer is author of Messengers of the Right: Conservative Media and the Transformation of American Politics. She is an assistant professor at the University of Virginia’s Miller Center and co-host of the Past Present podcast.