Donald Trump at Thursday’s debate. Photo: MANDEL NGAN/AFP/Getty Images

Having spent the past six weeks rhetorically slashing at his Republican rivals, it makes perfect sense that Donald Trump would eventually run out of targets and find himself in a war with the party’s media arm: Fox News. At the GOP primary debate Thursday night in Cleveland, Trump’s onstage clashes with the Fox moderators, and his postdebate complaints about the network’s treatment of him, were among the most talked-about story lines to emerge from the Quicken Loans Arena. What makes the confrontation all the more dramatic was that Fox News chairman Roger Ailes has, until this point, been a booster of the Trump candidacy, even to the chagrin of his boss, Rupert Murdoch. Whether Murdoch succeeded in turning Ailes against Trump, or not, the two-hour debate leaves little doubt that the relationship between the improbable front-runner and Fox has been upended.

It was a breakup days in the making. Over the past week, Ailes and his executives had been strategizing about how to deal with Trump. The prospect that the Donald could hijack the debate presented programming and political perils for both Ailes and his star anchors. What if Trump started insulting his GOP rivals onstage? Or broke the debate rules? During a meeting at Fox late last week, according to a source, senior Fox executives discussed a more worrisome scenario: What would happen if Trump won over the audience and moved the crowd to boo moderators Bret Baier, Megyn Kelly, and Chris Wallace on live television? What if Trump was able to direct his base of supporters to stop watching Fox? To prevent that from happening, Ailes needed a way to keep the audience firmly on the side of his moderators.

This political calculus might help explain why Baier opened the debate by asking all of the candidates to raise their hands if there was a chance they would not support the eventual Republican nominee or run as a third-party spoiler. After a beat, Trump’s hand was the only one to go up. The packed crowd inside the Quicken Loans Arena instantly started booing him. Baier then tightened the noose by laying out all the implications for the audience.

“Mr. Trump, to be clear, you’re standing on a Republican primary debate stage,” Baier said.

“I fully understand,” Trump replied.

“The place where the RNC will give the nominee the nod.”

“I fully understand.”

“And that experts say an independent run would almost certainly hand the race over to Democrats and likely another Clinton. You can’t say tonight that you can make that pledge?”

“If I’m the nominee, I will pledge I will not run as an independent. But — and I am discussing it with everybody, but I’m, you know, talking about a lot of leverage.”

The audience howled and hissed. Trump glared back like he was negotiating a thorny contract dispute. Whether Ailes scripted this or not, it was a triumph. While Trump may see politics as a negotiation, Ailes surely knew that the thousands of Republicans packed into the stands do not. So far, Trump has succeeded by presenting himself as the anti-politician who would save the country. Tonight, he looked like a spoiler. It could be that the visual of Trump being denounced onstage will prove to be every bit as devastating as Rick Perry’s “oops” or Mitt Romney “self-deportation” gaffes from the 2012 primaries.

It continued downhill from there. A short while later, Kelly asked Trump about his history of calling women he didn’t like “fat pigs, dogs, slobs, and disgusting animals.” Baier came back at him about his onetime support for a single-payer “Canadian” health-care system. Chris Wallace invoked his multiple bankruptcies. “Why should we trust you to run the nation’s business?” Wallace asked. Trump did his best to parry the questions and fought admirably. But to Ailes’s loyal audience, the message stood out as clearly as Trump’s hair: Fox was through with Trump.

And Trump, for his part, seemed to be through with Fox. “I thought the questions were not nice,” he told a crush of reporters after the debate. “I don’t think they were appropriate, and I think Megyn behaved badly.”

It’s not like the aggressive Fox questioning should have been a surprise. In the days leading up to the debate, Trump’s advisers expected Fox to be tough, especially Kelly, whom Trump has tangled with in the past. Earlier this week I reported that Trump’s friend Rudy Giuliani reached out to Ailes to ask that Kelly be fair to Trump. (Giuliani denied this.) In a phone call with a friend the other day, Trump grumbled about Fox’s on-air treatment of him. But even Trump’s campaign was taken aback by the intensity of the debate questions. Campaign lawyer Michael Cohen tweeted that it was a “total setup” designed to “lower #Trump2016 high poll numbers.” Another Trump adviser told me that the debate was “vicious” and a “hit job.”

It’s unclear what, ultimately, convinced Ailes to let his moderators go after Trump. He may have wanted to shoot first to prevent Trump from damaging Fox in a live situation, as they say in the business. Perhaps Murdoch got to Ailes. Or, perhaps, Ailes just wanted good television. (Fox did not respond to a request for comment.)

For Trump, whether this is a flesh wound or something deeper is also unclear. He’s surged to the top of the polls by winning every fight he’s picked so far. But for Trump’s troubled campaign, Ailes could prove to be a tougher opponent than any he’s faced. After all, no other candidate controls the television network that reaches the biggest block of primary voters. Those are the kind of poll numbers that are tough to beat.