He quit the day after video footage emerged of him kissing an aide in his ministerial office in a breach of coronavirus restrictions.
Images and video showed Mr Hancock in an embrace with aide Gina Coladangelo last month, and the Health Secretary was facing increasing pressure to quit over the breaking of social-distancing rules.
Mr Hancock wrote to Boris Johnson on Saturday and said: "The last thing I would want is for my private life to distract attention from the single-minded focus that is leading us out of this crisis.
"I want to reiterate my apology for breaking the guidance, and apologise to my family and loved ones for putting them through this. I also need to be with my children at this time."
He said: "We owe it to people who have sacrificed so much in this pandemic to be honest when we have let them down as I have done by breaching the guidance."
He paid tribute to NHS staff and Department of Health and Social Care (DHSC) officials and admitted that "we didn't get every decision right.”
But he said: "I know people understand how hard it is to deal with the unknown, making the difficult trade-off between freedom, prosperity and health that we have faced."
In a video posted on Twitter, Mr Hancock said: "I understand the enormous sacrifices that everybody in this country has made, you have made.
“And those of us who make these rules have got to stick by them and that's why I've got to resign."
There was also reaction from political opponents to Mr Hancock’s resignation.
Liberal Democrats leader Sir Ed Davey tweeted: "Matt Hancock s legacy as Health Secretary will be one of cronyism and failure.
"And the fact that Boris Johnson thought Hancock could just carry on regardless brings the Prime Minister's judgement into question once again."
Labour chair Anneliese Dodds tweeted: "A Health Secretary who behaved like rules didn't apply to him. A Prime Minister who didn't have the guts to remove him. A government riddled with sleaze. Now Matt Hancock has gone, the Prime Minister must clean up this crony government."