Prime Minister David Cameron came under intense fire Wednesday for his ties to journalists tainted by an escalating phone-hacking scandal, even as he proposed an extraordinary independent inquiry that could redefine the freewheeling rules of engagement between the press and politicians in Britain.

The scandal — in which thousands of victims including celebrities, members of the royal family and ordinary British citizens allegedly had their phones illegally hacked by journalists working for Rupert Murdoch’s News of the World tabloid — has severely damaged the operations of the paper’s parent company, News Corp. On Wednesday, the company was forced to withdraw its $12 billion bid to take full control of the lucrative British Sky Broadcasting Corp.

But the affair has also sullied Cameron, whose close personal ties to News Corp. executives dogged him in Parliament on Wednesday, presenting his Conservative-led coalition government with its most severe test since it came to power 14 months ago.

A sure-footed politician with a tongue sharpened by years of parliamentary sparring, Cameron, 44, is suddenly on the defensive. He confronted a chorus of boos Wednesday from the opposition Labor Party, whose 41-year-old leader, Ed Miliband, appears to have found his voice by seizing on the scandal.

Miliband blasted Cameron for hiring Andy Coulson, the former News of the World editor arrested last week in connection with the scandal, as his communications director. He demanded that Cameron release additional details about information his office received about Coulson before hiring him, referring to accounts given to Cameron aides by the Guardian newspaper. The opposition also pressed Cameron to agree to appear before an independent inquiry if called.

“Most of all,” Miliband said, “he should apologize for the catastrophic error of judgment he made in hiring Andy Coulson.”

Cameron has also come under fire for his ties to Rebekah Brooks, the embattled chief executive of News Corp.’s British division, News International, and former chief of News of the World from 2000 to 2003, when phone-hacking incidents allegedly took place. The two own rural homes within miles of one other and have gone horseback riding together. This past Christmas, Brooks entertained Cameron at a get-together at her home, according to British media reports.

Cameron and Brooks form what the media here call the “Chipping Norton set,” named after the area where they live, about 75 miles northwest of London. The set also includes another Cameron neighbor, Rupert Murdoch’s daughter Elisabeth, as well as her partner, the influential British PR guru Matthew Freud.

Cameron, who trod cautiously at first in condemning friends, appeared to break with them more clearly Wednesday. Using his strongest language yet, he said Brooks — who has reportedly offered her resignation, which Murdoch has not accepted — should step down. Brooks and Coulson have denied any knowledge of illegal newsgathering.

“She was right to resign. That resignation should have been accepted,” Cameron said in the House of Commons. “There needs to be root and branch change at this entire organization.”

On Coulson, who resigned from Downing Street in January as the scandal built, Cameron repeated his assertion that he never received specific evidence that his former spokesman was involved in “illicit behavior.” But he added, “if it turns out he lied, it won’t just be that he shouldn’t be in government, it should be that he should be prosecuted.”

Cameron is likely to be further dogged, however, by questions about Coulson’s hiring. The Guardian reiterated Wednesday that in February 2010 its editors had alerted Cameron aides that under Coulson’s watch, the News of the World had hired a private investor facing murder charges and known to have been working with corrupt police. Another attempt was made in October 2010, it said.

In a statement, Guardian editor Alan Rusbridger said: “The prime minister’s account of why he failed to act on the information we passed his office in February 2010 is highly misleading. Any ordinary person hearing of the unpublishable facts about a convicted News of the World private investigator facing conspiracy to murder charges would have recognized the need to investigate the claims.”

Many analysts say they believe Cameron will survive this test. But it nevertheless marks, they say, the first real stain on his credibility since assuming office and could undermine the Conservatives’ relationship with their coalition partners, the Liberal Democrats, whose members have been favorite targets of Murdoch’s tabloids.

More broadly, it could mark a major shift in the relationship between the British press and politicians — perhaps, some fear, to the point of challenging legitimate newsgathering. Cameron said he would now order all ministers and civil servants to record their meetings with newspaper and media owners, senior editors and executives.

British “politicians are going to be a lot more careful — they have slept with the devil for too long,” said Rodney Barker, professor of government at the London School of Economics.

More important, Cameron set in motion a landmark independent inquiry, including a panel with broad powers to call sitting and former politicians, journalists and police officers. Its mission would be to probe not only illegal behavior associated with News of the World and other British publications, but also to establish new “regulations” for the press.

Cameron added that British politicians have been “too silent” about media tactics in the past out of fear of the tabloids turning on them. “That is part of the problem,” he said. “Your bins are gone through by some media organization, but you hold back from dealing with it because you want good relations with the media.”

He continued, “What we need is some honesty about this issue on cross-party basis, so we can take on this problem.”

Special correspondents Karla Adam and Eliza Mackintosh contributed to this report.