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.
Cameron said he knew that Coulson's appointment would be "controversial" but that the party felt his experience as a tabloid editor meant he was tough enough for the high-pressure role.
He thought Coulson had done "the honorable thing" in resigning when the wrongdoing by his staff was uncovered, Cameron told the inquiry, and was willing to give him a second chance.
Asked if he regretted the appointment, Cameron acknowledged it had come back to haunt both him and Coulson. But, he said, "You don't make decisions with 20/20 hindsight.
"I made the decision I made," he said. "I don't try to run away from it, I just try to explain why I made it."
While in the role, Coulson performed well and behaved entirely properly, he added.
Cameron testified all day at the Leveson Inquiry, a wide-ranging investigation into media ethics and behavior currently examining the relationship between the media and politicians.
In April, Cameron told politicians in the House of Commons: "I think we all, on both sides of this house, did a bit too much cozying up to Mr. Murdoch."
The prime minister's testimony comes a day after Brooks appeared in court in connection with a separate police investigation into hacking.
She, her husband and four other people are charged with trying to obstruct the investigation.
Three people were arrested Thursday morning on suspicion of making inappropriate payments to police and public officials, the Metropolitan Police said. The probe into alleged bribery was set up alongside the police investigation into phone hacking.
Brown and another former prime minister, John Major, testified at Leveson Inquiry this week.
Brown lashed out Monday at Murdoch, his son and his British newspapers, raising the stakes in a highly charged and public battle between the two men.
The conflict could affect whether Murdoch keeps control of the British part of his media empire.
The former British leader flatly denied the most sensational claim that Murdoch made when he testified at the media ethics inquiry this year: that Brown had "declared war" on Murdoch's company when The Sun endorsed the Conservative party rather than Brown's Labour party in 2009.
"This conversation never took place. I am shocked and surprised" that Murdoch said it had when he was grilled at the inquiry in April, Brown said Monday. "There was no such conversation."
Brown repeatedly insisted that there was "no evidence" of the phone call, basing his assertion on phone records from his office when he was prime minister.
The media tycoon said in April that Brown had phoned him and threatened him when the Sun newspaper pulled its support for Labour and switched to the Conservatives.
"He said, 'Well, your company has made -- declared war on my government, and we have no alternative but to declare war on your company.' And I said, 'I'm sorry about that Gordon, thank you for calling.' End of subject," the News Corp. chairman testified.
After Brown essentially accused Murdoch of lying under oath, News Corp. said its chairman stood by his testimony.
If British media regulators feel Murdoch is not a "fit and proper person" to hold a British broadcasting license, he could theoretically be stripped of control of BSkyB, a lucrative part of his worldwide operations.
Murdoch's British operations are under scrutiny after revelations of widespread phone hacking by people working for his newspapers. Police and lawmakers are conducting separate inquiries into the scandal, separately from the Leveson Inquiry.
At her eight-minute hearing Wednesday, Brooks, the former top executive of Murdoch's British newspaper group, spoke only to confirm her address and was ordered to appear in Southwark Crown Court on June 22. She is charged with obstructing a police investigation into phone hacking and bribery.
Her husband, Charlie, and four current or former News International employees also face charges and appeared with her, becoming the first defendants to appear in court in connection with the wide-ranging police investigation sparked by allegations of illegal eavesdropping.
The defendants, who include Brooks' former personal assistant, driver and bodyguard, were ordered not to communicate with each other directly, except for Brooks and her husband.
Cheryl Carter, the personal assistant, was also instructed to surrender her passport.
The six were charged last month with perverting the course of justice.
They are accused of plotting to remove seven boxes of documents from News International offices and hide computers and documents from police.
When she was charged in May, Brooks blasted British prosecutors, calling the case "an expensive sideshow."
She said she is "baffled" and angered by the decision to charge "those closest to me."
"One day, the details of this case will emerge, and people will see today as nothing more than an expensive sideshow -- a waste of public money as a result of an unjust and weak decision," she told reporters outside her lawyer's office.
Charlie Brooks said that his wife is the victim of a "witch hunt" and that the charges against him and others are "an attempt to use me and others as scapegoats, the effect of which is to ratchet up the pressure on my wife."
Cameron established the Leveson Inquiry amid British public anger at the News of the World about the hacking of Milly Dowler's voice messages.
Her case came on top of apologies from the tabloid for the hacking of the phones of celebrities and politicians, and proved to be the last straw for the paper, which was shut down in July.
The inquiry is intended to explore media ethics in Britain more widely, alongside police investigations into phone hacking, e-mail hacking and police bribery by people working for Murdoch's British newspapers.
CNN's Bharati Naik contributed to this report.