LONDON (CNN) -

British Prime Minister David Cameron was quizzed Thursday about his links to former top Murdoch executive Rebekah Brooks and his decision to hire former News of the World editor Andy Coulson.

Cameron himself set up the inquiry into media ethics in response to phone hacking at the News of the World, the Rupert Murdoch-owned tabloid that shut down over illegal eavesdropping.

He has faced questions about his judgment as the scandal has unfolded, amid suggestions that his government was too closely connected to Murdoch's media empire.

Questioned about his ties to Brooks, who was also previously editor of the Sun and the News of the World, Cameron said their friendship had developed over several years, particularly after she married his friend and neighbor, Charlie Brooks.

A text sent by Rebekah Brooks to Cameron on the eve of a major speech by him to the Conservative party annual conference appeared to show a close relationship.

"I am so rooting for you tomorrow, not just as a personal friend but because professionally we are in this together," she wrote.

Cameron said he understood "we are in this together" to refer to the Sun's support for the Conservative party.

The Sun -- the UK's most popular newspaper, with a daily circulation of 7 million -- switched allegiance from Labour to the Conservatives in 2009, a week before Brooks sent the text.

Cameron also had meetings with James Murdoch, the son of Rupert Murdoch and a senior News Corp. executive.

His government's handling of News Corp.'s bid to take full control of British satellite broadcaster BSkyB has come under scrutiny in recent months, following the revelation of apparent back-channel communications between the company and an aide to Jeremy Hunt, the Cabinet minister who oversees British broadcasting.

News Corp. eventually dropped the bid amid the furor over the phone hacking scandal.

Questioned about the appropriateness of appointing Hunt -- who had previously openly supported the BSkyB bid -- to adjudicate it, Cameron said it had seemed the best solution at the time to a political problem. The move had been approved by lawyers and civil servants, he said, and Hunt had acted properly at every point in the process.

The prime minister earlier said relations between politicians and the media were "too close and unhealthy" but rejected the idea that he had made promises about government policies, for example on media regulation, in return for newspapers' support.

"There was no overt deal for support, there was no covert deal, there were no nods or winks," he said.

He acknowledged trying to win over different media organizations to back his party, but insisted he was "not trading policies for that support. And when you look at the details of this, it is complete nonsense."

He rejected as a cooked-up "conspiracy theory" a suggestion by his predecessor as prime minister, Gordon Brown, that a deal had been struck between the Conservatives and News International, a British arm of News Corp.

Cameron said the inquiry was doing the job it was meant to in trying to "get to the bottom of the media-political relationship and put it on a firmer footing."

Asked how the relationship could work better, Cameron said more distance, formality and respect were called for on both sides.

A new regulatory system is needed for the press because the current self-regulation process "is not working," he said.

The rules should work to protect ordinary people, some of whom have been terribly mistreated by the press, rather than being drawn up to make the media or politicians happy, he added.

He said the pain of the Dowler family had been "trebled" by the hacking of voice mail messages of their missing teenage daughter, Milly, who turned out to have been murdered. The News of the World was shuttered amid public anger about the scandal.

Earlier in the day, Cameron defended his decision to appoint former News of the World editor Andy Coulson as director of communications for the Conservative Party and then in Downing Street, saying he was the best person for the job.

Coulson resigned from the Downing Street role last year when police began a new phone hacking investigation, saying it had become a distraction. He quit the News of the World after two employees were jailed over phone hacking in 2007 but denies knowing of wrongdoing while he was in charge.

Coulson was this month arrested and charged with perjury over court testimony about phone hacking, according to Britain's Press Association news agency.

Asked about the hiring process, Cameron said Coulson had given him and others assurances that he knew nothing of the phone hacking while he was editor.