“You live and you learn,” he added, “and, believe you me, I have learned.”

Mr. Cameron also took on Mr. Miliband, saying that most of the abuses now under investigation within the Murdoch newspapers took place when Labour was in power and that the Labour governments of Tony Blair and Gordon Brown had taken no action on evidence that serious wrongdoing had occurred. He also said that Labour’s ties with Mr. Murdoch and his executives, and the party’s pursuit of Mr. Murdoch’s political favor, were more extensive than his own.

“I can assure the House that I’ve never held a slumber party or seen her in her pajamas,” Mr. Cameron said, referring to Rebekah Brooks, a onetime editor of The News of the World, who resigned as chief executive of News International, the paper’s parent company, late last week. The gibe referred to a gathering Mr. Brown’s wife held in 2008 at the prime minister’s country retreat, which British newspaper accounts have said was attended by Ms. Brooks; Mr. Murdoch’s wife, Wendi; and his daughter Elisabeth. A Daily Mail account said guests were told to bring their pajamas “for the sort of sleepover usually favoured by teenage girls.”

Mr. Cameron’s defense on Wednesday — and his continuing vulnerability — rested on two potentially explosive issues. First was why he hired Mr. Coulson only months after Mr. Coulson’s 2007 resignation as The News of the World’s editor, then took him to Downing Street, in the face of a flurry of private warnings, after the Conservatives won the May 2010 general election.

The Coulson hiring had raised eyebrows among many in the Conservative Party and elsewhere because of the jailing in 2007 of the paper’s former royalty correspondent and a private investigator for tapping the voice mail messages of Prince William. Mr. Coulson has denied knowledge of the phone hacking, as have all other top editors and executives at the Murdoch papers.

The second issue that led to waves of hostile questioning from Labour was what role Mr. Cameron played in the government’s initial decision to support Mr. Murdoch’s $12 billion bid for British Sky Broadcasting, or BSkyB, Britain’s most lucrative satellite television network. The questions were prompted, in part, by Downing Street’s acknowledgment last week that Mr. Cameron had met 26 times with Rupert Murdoch and other executives and editors of his British media properties in little over a year in office.