Mr Javid’s appointment came the day after video footage emerged of Mr Hancock kissing an aide in his ministerial office in a breach of coronavirus restrictions.
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.”
A statement from No10 released around 90 minutes later said: “The Queen has been pleased to approve the appointment of the Rt Hon Sajid Javid MP as Secretary of State for Health and Social Care.”
Mr Javid said he was “honoured” to take up the role.
“I look forward to contributing to our fight against the pandemic, and serving my country from the Cabinet once again.”
Bringing Mr Javid back into government means that Boris Johnson can avoid a wider shake up of his ministerial team following Mr Hancock’s resignation.
The Bromsgrove MP previously served as home secretary from 2018 to 2019 and then as chancellor until February last year when he was replaced by Rishi Sunak in a No10 power struggle.
At the time, Mr Javid said he had “no option” but to resign as chancellor - because Boris Johnson attached conditions to him staying in the role which “no self-respecting minister would accept”.
He quit after refusing to sack his aides in a row with the PM.
Mr Javid had also clashed with the PM’s former chief adviser Dominic Cummings.
In August 2019, Mr Cummings had fired Mr Javid’s aide Sonia Khan, who later settled a claim for unfair dismissal with the Government.
On Saturday, Mr Cummings criticised the appointment of Mr Javid, claiming he was “bog standard” and would be “awful” for the NHS.
But London mayor Sadiq Khan, whose father like the new health secretary’s, was a bus driver, tweeted: “Always good to see the children of bus drivers do well! Congrats.
“Look forward to working together to protect our communities from this awful pandemic, get London vaccinated and continue opening up our city and country safely.”
Former health secretary Jeremy Hunt described Mr Javid’s appointment to the role as an “excellent choice”.
Mr Hunt, now chairman of the Commons’ Health Select Committee, tweeted: “I worked closely w/him 4 many years & found him smart, decent &(perhaps rarely in the trade) 100% full of integrity.”
However, 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.”