Former chancellor and home secretary Mr Javid was appointed to the prominent role just 90 minutes after Downing Street announced Mr Hancock had resigned on Saturday evening.
It came the day after video footage emerged of the married then Health Secretary kissing an aide in his ministerial office in a breach of coronavirus restrictions.
Images and video showed Mr Hancock in an embrace with married aide Gina Coladangelo last month, and Conservative MPs told of how their inboxes had filled with complaints similar to those they received during Dominic Cummings’s infamous trip to Barnard Castle during a national lockdown.
In a letter to the Prime Minister, Mr Hancock 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.”
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.
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.”
Various outlets including the BBC, The Sunday Mirror, and The Sunday Telegraph reported that Mrs Coladangelo would also be leaving her DHSC job, but the department had not confirmed this on Saturday night.
Mr Javid’s appointment, on the other hand, marked a return to the top of politics after he abruptly left the Cabinet in shock fashion some 16 months ago.
He was just six months into his role as chancellor, and less than a month away from delivering his first Budget, when he quit after being told to sack all his advisers if he wanted to keep his job.
His departure in February last year came after a bruising Whitehall power struggle with Boris Johnson’s then chief adviser Dominic Cummings.
But in a reversal of fortunes it is Mr Javid who returns to Boris Johnson’s top team, while Mr Cummings hurls criticism from outside Government.
Mr Javid tweeted: “Honoured to have been asked to serve as Secretary of State for Health and Social Care at this critical time.
“I look forward to contributing to our fight against the pandemic, and serving my country from the Cabinet once again.”
Although he has resigned, questions are unlikely to go away for Mr Hancock regarding the employment of university friend Mrs Coladangelo, who was first brought in to the department as an unpaid adviser and then given a £15,000-a-year job as a non-executive director.
Labour has called on all documents related to her employment to be released.
In response to Mr Hancock’s resignation, the Prime Minister wrote: “Above all, it has been your task to deal with a challenge greater than that faced by any of your predecessors, and in fighting Covid you have risen to that challenge – with the abundant energy, intelligence, and determination that are your hallmark.”
Mr Johnson had stuck by Mr Hancock, refusing to sack him as No 10 said the PM considered the matter closed following an initial apology.
But Conservative MPs began to break ranks to call for Mr Hancock to go.
Veteran Tory Sir Christopher Chope (Christchurch) said his constituents were “seething”.
And Andrew Bridgen, Tory MP for North West Leicestershire, said that a “sizeable minority or even a majority of the public no longer had confidence in Matt Hancock”.
Mr Javid takes over the job not only with coronavirus to contend with, but NHS reform, battles over pay, a lack of a plan for social care, the appointment of a new NHS chief executive, and a huge backlog for treatments.
Dr Chaand Nagpaul, the British Medical Association’s chair of council, said: “Sajid Javid has a huge and urgent task ahead.
“He must ensure completing the roll-out of the adult vaccination programme at rapid pace to control spiralling infection rates. He must also put forward a credible plan to tackle a backlog of care of unprecedented scale whilst at the same time rebuilding the trust of doctors and the wider healthcare workforce.”
Labour’s shadow health secretary, Jonathan Ashworth, said: “Sajid Javid failed to reverse the previous eight years of social care cuts or deliver the investment our NHS needed in his time as chancellor of the Exchequer.
“He now needs to explain how he will bring down sky-high waiting lists, ensure people get the cancer care they need, get young people vital mental health support and crucially fix social care, which has suffered swingeing cuts under the Conservatives.”