Former Fox News chief Roger Ailes is now helping Donald Trump prepare for the upcoming presidential debates, sources with knowledge of the matter confirmed.

While not serving in a formal role, Ailes is a longtime friend of Trump's and the two speak frequently, the sources said. With the first presidential debate approaching on September 26, their conversations have increasingly turned toward Trump's approach to Hillary Clinton on the debate stage.

Ailes and Trump were also together in person at Trump's golf club in Bedminster, New Jersey, this weekend, one of the sources said.

Ailes and Trump have also discussed other matters related to his campaign, the sources said, though they declined to specify what those were. Ailes was ousted from his Fox News job last month amid sexual harassment allegations.

The Trump campaign denied a New York Times report that Ailes was advising Trump on the debates, even as it acknowledged that the two men were "longtime friends."

"This is not accurate," Trump spokeswoman Hope Hicks said in a statement. "He is not advising Mr. Trump or helping with debate prep. They are longtime friends, but he has no formal or informal role in the campaign."

Related: Ailes, Trump have been counseling each other over the past week

Political and media insiders have long speculated that Ailes would take on an informal advisory role with Trump's campaign following his ouster from Fox News.

As CNNMoney previously reported, Ailes and Trump counseled each other in multiple phone calls leading up to Ailes' departure from the network in late July.

For Trump, who is lagging in the polls and currently at risk of losing even reliably Republican states, Ailes' advice is an invaluable asset.

Before launching Fox News in 1996, Ailes was a political adviser to Presidents Richard Nixon, Ronald Reagan and George H.W. Bush. He is widely credited with refashioning Nixon's image and helping him win the 1968 election.

But given that he is facing a litany of sexual harassment allegations, Ailes' associations with Trump could also become a liability among female voters -- a demographic with which Trump is already struggling.