Before the relationship between the two men soured, Roger Ailes was lurking in the shadows of Donald Trump's campaign, referred to in media reports as his "debate whisperer" for helping the billionaire Republican prepare for his on-screen debates.

Ailes, the founder and former boss of right-wing television channel Fox News, who left the company in disgrace in July 2016 amid allegations of sexual misconduct, died on 18 May. He was 77. The cause of his death is currently unknown but he had suffered ill health.

The media mogul Rupert Murdoch, who owns the Fox Broadcasting Company, took over from Ailes after he left the company over claims he sexually harassed the news anchor Gretchen Carlson. Fox settled out of court with Carlson for $20m. As many as 20 other women have raised similar issues about Ailes.

President Trump "talks about how the coverage under Murdoch is better than under Ailes," a White House source told CNN in April, a sign of how relations had worsened.

Gabriel Sherman, the national affairs editor at New York Magazine, who wrote a book about Ailes, tweeted that a Fox News source told him Trump was heard on a microphone saying: "Rupert's been a lot better to me than Roger ever was."

Roger Ailes resigns
Roger Ailes was a background adviser to Donald Trump during his election campaign Reuters

"Trump and Ailes have known each other for decades," Sherman told the Washington Post in August 2016. "They're friends in the 'we're-both-Manhattan-media-power-brokers' sense. More recently, Ailes helped propel Trump's unlikely political career by giving him a weekly call-in segment on Fox & Friends."

Ahead of Trump's launch of his presidential candidacy, the pair met for lunch, and Ailes agreed to help his campaign. To that end, Ailes would give Trump talking points for his debates, first with Republican rivals and then with Hillary Clinton, to help sharpen up his performances.

Even when Trump feuded with Fox News host Megyn Kelly, whose questioning on his misogynistic comments about women he took umbrage with during a debate in the Republican primaries, Ailes continued to support the campaign.

Roger Ailes Rupert Murdoch
Rupert Murdoch announces Roger Ailes would head the new Fox 24-hour news network in 1995 Reuters

Ailes also reviewed campaign adverts for Trump, according to the New York Times. And all that work paid off when Trump won the US election.

But Ailes wasn't there until the end. The working relationship broke down well before Trump's election. "Ailes's camp said Ailes learned that Trump couldn't focus – surprise, surprise – and that advising him was a waste of time," Sherman told the Vanity Fair New Establishment Summit in October 2016. "These debate prep sessions weren't going anywhere."

But Vanity Fair contributing editor Sarah Ellison said the Trump team fired the blame right back: "Even for the second debate, Ailes kept going off on tangents and talking about his war stories while he was supposed to be prepping Trump."

As the sexual harassment scandal engulfed Ailes, his hidden past surfacing during the election campaign, Trump quickly distanced himself. "I only speak to Roger on occasion now," Trump said on Newsmax.