In a letter to Prime Minister David Cameron, Dr Fox said that he had “mistakenly” allowed the distinction between his personal interest and government activities to become “blurred”.
“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,” he said.
“I have therefore decided, with great sadness, to resign from my post as Secretary of State for Defence - a position which I have been immensely proud and honoured to have held.”
In his response, Mr Cameron paid tribute to the “superb job” which Dr Fox had done at the Ministry of Defence.
“I understand your reasons for deciding to resign as Defence Secretary, although I am very sorry to see you go,” he said.
“We have worked closely for these last six years, and you have been a key member of my team throughout that time.”
The announcement comes after days of damaging speculation over the relationship between Dr Fox and his 33-year-old best man and former flatmate.
Mr Werritty was questioned for a second time today by a senior official from the Cabinet Office as part of the Whitehall investigation headed by Sir Gus O’Donnell.
Employment Minister Chris Grayling, a close ally of Dr Fox who was his campaign manager during the 2005 campaign for the Conservative leadership, said he had taken a “brave and probably correct decision”.
Mr Grayling, who spoke to the former defence secretary following his decision to resign, told the Press Association: “It is a great shame. I am very saddened for Liam.
“He has done a really good job in turning around the Ministry of Defence at an extraordinarily difficult time.
“I very much hope that in due course he will be able to make a return to government.”
Shadow defence secretary Jim Murphy said: “This was unavoidable and inevitable.
“Throughout these events I haven’t called for Liam Fox’s resignation but just the full truth.
“Governments must have rules and ministers must have standards. Liam Fox fell foul of the standards and he broke the rules. It was clear early on that he had breached the Ministerial Code.”
He added: “This issue has centred solely on his judgment and his conduct in one of the most serious jobs in the country.
“With so much at stake for our forces, the Defence Secretary must be focused solely on his public duties.
“The Government has shown how out of touch it is by spending the whole of the last week worrying about how to save Liam Fox’s job. That time should have been better spent trying to save the jobs of tens of thousands of hard-working people.”
Tory backbencher Mark Pritchard said he hoped Dr Fox could return to government at some stage.
“Liam Fox will be remembered as a defence secretary who started the necessary fundamental reform of the Ministry of Defence,” he said.
“He inherited a £38 billion black hole from Labour which he successfully tackled while maintaining the necessary levels of defence for the nation.
“That reconciliation was a very difficult test yet he undertook it with skill and understanding of defence issues.”
He added: “I hope that in the future he could return to the government.”