Defence Secretary Liam Fox has resigned after a week of pressure over his working relationship with friend and self-styled adviser Adam Werritty.
Mr Fox was being investigated amid claims he broke the ministerial code.
In a letter to David Cameron, Mr Fox said he had "mistakenly allowed" personal and professional responsibilities to be "blurred".
Mr Cameron said he was very sorry to see him go. Transport Secretary Philip Hammond will replace Mr Fox.
Labour said Mr Fox had not upheld the standards expected of ministers and his departure had been "inevitable".
The defence secretary has been under pressure since it emerged that Mr Werritty, a lobbyist, had met him on 18 foreign trips despite having no official role.
Mr Werritty, a former flatmate of Mr Fox and the best man at his wedding, handed out business cards suggesting he was his adviser and was present at meetings Mr Fox had with military figures, diplomats and defence contractors.
Questions were also raised about who paid for Mr Werritty's business activities and whether he had personally benefited from his frequent access to the defence secretary.
No 10 sources said that the prime minister had been willing to give Mr Fox time to stay in his job - at least until the details of a report by Cabinet Secretary Sir Gus O'Donnell into his conduct were published early next week.
Mr Fox has been replaced by Transport Secretary Mr Hammond. In a mini-reshuffle caused by Mr Fox's departure, Treasury minister Justine Greening has replaced Mr Hammond - becoming the fifth woman in the Cabinet.
In a statement released on Friday night, Mr Hammond said his predecessor had done a "brilliant job".
"I look forward to picking up the baton from Liam and working closely with the prime minister, foreign secretary and international development secretary to ensure that our defences are robust and that the finances that lie behind them are equally robust," he added.
In his resignation letter, Mr Fox said he had "mistakenly allowed the distinction between my personal interest and my government activities to become blurred".
"The consequences of this have become clearer in recent days," he added. "I am very sorry for this.
"I have also repeatedly said that the national interest must always come before personal interest.
"I now have to hold myself to my own standard. I have therefore decided, with great sadness, to resign from my post as secretary of state for defence."
Responding to Mr Fox's resignation, Mr Cameron said: "I understand your reasons for deciding to resign as defence secretary, although I am very sorry to see you go.
"We have worked closely for these last six years, and you have been a key member of my team throughout that time."
He said Mr Fox, MP for North Somerset for 19 years, had "done a superb job in the 17 months since the election, and as shadow defence secretary before that" and had overseen changes that would allow the armed forces to "meet the challenges of the modern era".
The BBC's political editor Nick Robinson said the prime minister had given Mr Fox time to defend himself but the defence secretary had struggled to stem the tide of questions about his dealings with Mr Werritty.
No 10 had come to the conclusion on Thursday that Mr Fox's position was becoming untenable, he added, and Mr Fox had reluctantly reached the same view.
Mr Fox apologised to MPs earlier this week about how his links with Mr Werritty had been perceived but he maintained there had been no impropriety.
Labour said Mr Fox had "fallen foul of the standards expected of ministers and broken the rules".
"The facts have caught up with Liam Fox and he had to resign," shadow defence secretary Jim Murphy said. "It was inconceivable that once a minister had been seen to break their own code of conduct on so many occasions that he could survive."
And former Lib Dem leader Sir Menzies Campbell said recent events had undermined Mr Fox's authority and morale at his department.
"Mr Fox has bowed to the inevitable," he said. "It had become impossible for him to draw a line under the story."
But Conservative MPs rallied behind Mr Fox, saying he had made a major contribution in his time at the Ministry of Defence and some suggested he could, one day, return to government.
Sir Malcolm Rifkind, a former defence secretary, said Mr Fox had done an "extremely good" job and his departure was "very, very distressing" as it would lead to further upheaval at the MoD.
Conservative backbencher Peter Bone told the BBC Mr Fox had made errors but they did not constitute a "hanging offence".
"He said he made mistakes and with hindsight he wouldn't have done it but I didn't think that was enough to require him to resign," he said.
"But when the story, every news item, isn't about what's happening in Afghanistan and what's happening in Libya but who said what to who then he put his country first and resigned."
David Pasley, a Tory councillor in Mr Fox's North Somerset constituency, described the MP as "hard working" and "diligent", and said he was "deeply saddened" by Friday's events.
But he added: "He's someone who you can't keep down.
"He has got such experience in his political career that I'm sure it will just be a question of time before he's back, and I hope he's back very soon in a high profile position."