Downing Street communications chief Andy Coulson has quit after admitting the News of the World phone-hacking row was making his job impossible.
In a personal statement issued by Number 10, Mr Coulson said the drip-drip of claims about illegal eavesdropping under his editorship meant he could not "give the 110% needed".
"I stand by what I've said about those events but when the spokesman needs a spokesman it's time to move on," he added.
The Prime Minister said he was "very sorry" that Mr Coulson felt "compelled" to go after months of intense pressure, insisting he was being "punished for the same offence twice".
But critics insisted the resignation was "long overdue", and questioned Mr Cameron's judgment in recruiting the former journalist in the first place.
The timing also sparked accusations that the Government was trying to "bury bad news" while Tony Blair was appearing at the Iraq Inquiry, and with the furore over shadow chancellor Alan Johnson's departure still raging.
Last week Mr Cameron refused to confirm or deny reports that his communications director had offered to resign to spare the coalition further damage.
But he conceded that Mr Coulson was "extremely embarrassed" about claims that he knew famous people's phone voicemails were being accessed.
It is understood Mr Coulson informed the prime minister of his intention to leave on Wednesday evening. No decision has yet been taken on a replacement.
Mr Coulson resigned as editor of the News of the World in 2007 after the paper's former royal editor Clive Goodman and private investigator Glenn Mulcaire were jailed for phone hacking.
Although he accepted ultimate responsibility for the illegal activities, he has always denied knowing they were taking place. A Scotland Yard investigation resulted in no further charges.
But a number of public figures are still taking civil legal action against the newspaper, and documents disclosed in those cases have sparked fresh developments.
It emerged earlier this month that News of the World executive Ian Edmondson has been suspended as a result of claims in a case brought by actress Sienna Miller.
Police subsequently wrote to the newspaper asking for any new evidence staff had on the case.
The Crown Prosecution Service (CPS) has asked a senior QC to "comprehensively" re-examine material amassed as part of the original inquiry and any new evidence.
In his resignation statement today, Mr Coulson said: "Nothing is more important than the Government's task of getting this country back on its feet.
"Unfortunately continued coverage of events connected to my old job at the News of the World has made it difficult for me to give the 110% needed in this role.
"I stand by what I've said about those events but when the spokesman needs a spokesman it's time to move on.
"I'll leave within the next few weeks and will do so wishing the Prime Minister, his family and his brilliant and dedicated team the very best for what I'm sure will be a long and successful future in Government."
Mr Cameron responded in a statement: "I am very sorry that Andy Coulson has decided to resign as my director of communications, although I understand that the continuing pressures on him and his family mean that he feels compelled to do so.
"Andy has told me that the focus on him was impeding his ability to do his job and was starting to prove a distraction for the Government."
Speaking to reporters later, the Prime Minister said he believed Mr Coulson had been "punished for the same offence twice".
"He's run the Downing Street press office in a professional, competent and good way," he insisted. "He's done an excellent, excellent job. I think he should be judged by that. This is all about the past. It's just gone on and on."
A Downing Street source branded the idea that it had been trying to "bury bad news" as "complete rubbish".
"We have knocked two very bad news stories of Labour's off the top of the bulletins," they said.
The source also insisted the resignation had not been prompted by any particular development in the phone hacking saga.
But Labour leader Ed Miliband said: "The cloud of allegations surrounding Andy Coulson's tenure at the News of the World raised real questions about his ability to be at the heart of the Downing Street machine.
"He's now done the right thing but he should have done it earlier. I think it raises real questions about David Cameron's judgment that he hung on to Andy Coulson for so long."
And Opposition frontbencher Chris Bryant said he hoped the police would now conduct a thorough investigation into the phone hacking.
"To say this is long overdue is an understatement," he added. "Andy Coulson should never have been appointed in the first place."Reuse content