The prime minister's communications chief Andy Coulson has resigned, blaming coverage of the News of the World phone hacking scandal.
Mr Coulson said coverage had "made it difficult for me to give the 110% needed in this role".
He faced pressure after claims about phone hacking while he was editor.
Mr Coulson quit as editor in 2007 saying he took ultimate responsibility for the scandal. He denied knowing phone hacking was taking place.
In a statement on Friday, he said it had been "a privilege and an honour to work for David Cameron for three-and-a-half years".
But he added: "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."
He said he would leave within weeks and was proud of the work he had done.
In a statement Mr Cameron praised him as a "brilliant member of my team".
The prime minister said: "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."
Asked if it raised questions about his own judgement, Mr Cameron said: "I don't think so at all because Andy Coulson resigned from News of the World when he found out what was happening, I feel that he has been punished twice for the same offence.
"I choose to judge him by the work he's done for me, for the government and for the country and he has run the Downing Street press office in a professional and competent and good way."
Mr Coulson was editor of the News of the World in 2007 when its royal editor, Clive Goodman, was jailed for conspiracy to access phone messages. Private investigator Glenn Mulcaire was jailed for six months on the same charge.
Mr Coulson denied any knowledge of phone hacking but resigned saying, as editor, he took "ultimate responsibility". A Press Complaints Commission investigation in May 2007 found no evidence that he or anyone else at the paper had been aware of Goodman's activities.
That same month he became Mr Cameron's director of communications.
But pressure has recently mounted on Mr Coulson, amid renewed newspaper investigations into the scale of phone hacking at the Sunday tabloid. Mr Coulson himself was interviewed as a witness by police in November.
In December, Director of Public Prosecutions Keir Starmer said no new charges would be brought in the case, owing to a lack of admissible evidence.
But some public figures are taking civil legal action against the newspaper, and documents disclosed in those cases have led to new developments.
Earlier this month the News of the World suspended its news editor, Ian Edmondson, over allegations of phone hacking in 2005-6, thought to involve the actress Sienna Miller.
Asked about Mr Coulson's resignation, Labour leader Ed Miliband said: "We think he should have gone earlier, he has now done the right thing. I think there are questions about David Cameron's judgement about hanging on to him as long as he did."
But other Labour MPs accused Mr Coulson of deliberately announcing his resignation on a busy news day - when former Labour PM Tony Blair is before the Iraq Inquiry, and in the aftermath of Alan Johnson's shock resignation as shadow chancellor.
In the Commons on Friday, former minister Denis MacShane demanded that the prime minister make a statement "rather than bury this news on a day when, frankly, there's an awful lot of other news taking place".
His colleague Tom Watson added: "It's a mark of the man that he would sneak out a statement on a Friday morning on a busy news day.
"Spin and obfuscation is all we get from Downing Street - we need to get to the truth."
A Downing Street source said it was "complete rubbish" to suggest they were trying to bury bad news: "We have knocked two very bad news stories of Labour's off the top of the bulletins."
BBC political editor Nick Robinson said he understood that Mr Coulson informed the prime minister on Wednesday evening of his wish to resign and they had arranged then for it to be announced on Friday.