Rebekah Brooks told David Cameron that News International and the Conservative Party were "in this together" in the run up to the 2010 general election, the Leveson inquiry has heard.
A text message sent by Brooks, the-then chief executive of News International, to Cameron on the eve of his last conference speech as leader of the opposition also contained the rather embarrassing sign-off: "Yes, He Cam" - a line that The Sun newspaper splashed on the following day.
The text sent on 7 October 2009 read: "But seriously I do understand the issue with the Times. Let's discuss over country supper soon.
"On the party it was because I had asked a number of NI [News International] people to Manchester post endorsement and they were disappointed not to see you.
"But as always Sam was wonderful (and I thought it was OE's [Old Etonians] were charm personfied!) I am so rooting for you tomorrow not just as a proud friend but because professionally we're definitely in this together! Speech of your life? Yes he Cam."
The News International-owned tabloid ran the headline 'Yes, he Cam' the day after Cameron had delivered his keynote conference speech.
The previous day George Osborne had used the line "we're all in this together" in reference to public spending cuts for the first time during a speech to the Conservative Party conference.
In his evidence to the Leveson inquiry today, Cameron acknowledged that he and Brooks had become particularly friendly after she married his childhood friend Charlie Brooks - who lives in his Oxfordshire constituency.
Despite revealing the close relationship he holds with Brooks, the PM insisted it did not demonstrate any wrong-doing.
"The Sun wanted to make sure it was helping the Conservative Party put its best foot forward," he said. "We were going to be pushing the same political agenda."
The newspaper had switched its support from Labour to the Tories during the Labour party conference a few weeks earlier.
Brooks has previously laid bare the closeness of her friendship with the prime minister - including his habit of signing off texts "LOL" apparently in the belief it meant "lots of love".
He sent a message urging her to "keep your head up" when she too resigned over the phone hacking scandal and expressed regret that he could not be more loyal, she disclosed to the inquiry last month.
Cameron launched an angry attack on his predecessor Gordon Brown for suggesting that the Conservative Party had done a "deal" with Rupert Murdoch to bring in policies favoured by News Corporation in return for favourable press coverage.
"There was overt deal for support, there was no covert deal, there were no nods and winks," he said.
Brown was "angry and disappointed" that The Sun had decided to ditch its support for Labour and returned to the Conservatives.
"He has cooked up an entirely specious and unjustified conspiracy theory to justify his anger," the prime minister said.
Cameron told the inquiry that while he wanted to win over the newspapers this did not mean he promised to give media proprietors such as Murdoch a "better time" on various policies.
In a further criticism of Brown he told Leveson that when he arrived in Downing Street in May 2010 it was set up "like a newsroom" in order to engage "permanently in a news warfare mode".
He said he reorganised his private office so he was "not sitting under a 24-hour news televison screen and worrying about the ticker and what's happening every hour".
Cameron told the inquiry that his long-held views about media regulation in the UK formed when he worked for a major commercial broadcaster in the 1990s.
As he began his evidence under oath at the Royal Courts of Justice, the prime minister said his seven years as corporate affairs director at Carlton "was quite a formative period".
The Tory leader has submitted an 84-page witness statement and three exhibits to the inquiry and will be questioned about them in an all-day session.
Asked about his time in television before quitting for a political career, he said: "Carlton was quite a formative period.
"I formed a lot of views about the media then which I still hold today."