REBEKAH Brooks texted David Cameron to tell him that they were "in this together" days after the newspaper she edited deserted Labour for the Tories, it has emerged.

In the message, handed over after it was ordered by the Leveson Inquiry, she also told Mr Cameron "Yes, he Cam!"

The politically embarrassing text was released a day after Mrs Brooks, one of Rupert Murdoch's most trusted executives, appeared in court charged with perverting the course of justice.

During a highly anticipated appearance at the inquiry, the Prime Minister vehemently denied Gordon Brown's allegation that the price of support from The Sun was backing for Murdoch's BSkyB bid.

Mr Cameron also admitted that his decision to hire controversial spin doctor Andy Coulson "haunted him".

But he denied he had hired the former editor of another Murdoch paper, the News of the World, because of his closeness to the media mogul.

Last night, Downing Street said it did not have records of any more texts between the Prime Minister and Mrs Brooks.

Asked if the inquiry had ordered Number 10 to hand such texts over, a spokesman said: "We have provided whatever they asked for."

However, he appeared to confirm that the Conservative leader and Mrs Brooks were still friends, adding: "They have not had a significant amount of contact recently."

The controversial text was sent the week after The Sun came out for the Conservatives in 2009.

In it, Mrs Brooks wrote that they would discuss "over country supper soon" Mr Cameron's non-appearance at a party organised by another Murdoch-owned paper, the Times. Mentioning his imminent conference speech, she added: "I am so rooting for you tomorrow not just as a proud friend but because professionally we're definitely in this together!"

She ended her message with a paraphrase of Barack Obama's campaign slogan, writing "Speech of your life? Yes he Cam!"

Mr Cameron told the inquiry that he had wanted to win support from journalists and newspapers when he took over the Tory party in 2005.

But he denied that he had ever offered proprietors control over policy in return.

He revealed that Rupert Murdoch's son James had specifically told him that The Sun would dump Mr Brown during Labour's party conference, a week before the Conservative event. But he hit out at his predecessor in Number 10 as he angrily denied accusations that he had done a deal over the Murdochs' commercial interests.

The allegation was "complete nonsense", he said.

"Gordon Brown was very angry and disappointed that The Sun had deserted him and he has cooked up an entirely specious and unjustified conspiracy theory to justify his argument," he told the inquiry.

He added: "There was no overt deal, there was no covert deal, there were no nods and winks."

He suggested he was the victim of a "witch-hunt", citing allegations of the perception of murky dealings despite a lack of evidence.

During five hours in the witness box, the Prime Minister also said that he felt it was his Government's "duty" to clean up the press in the wake of the phone-hacking scandal.

He warned newspapers he did not think they could continue with a system of self-regulation, pressing instead for "independent" regulation.

However, he said that politicians must not be in charge of imposing restrictions on the press, adding that the process could not be seen as "revenge for the expenses scandal", which engulfed Westminster in 2008 and led to a number of politicians being sent to jail.

Mr Cameron also defended ministers' rights to have personal friends and said they should not have to record every meeting with them, even if they were journalists or media executives.