What resolved him to quit, he told the BBC's Sunday Morning show, was hearing a sermon on integrity at a prayer breakfast in Parliament on Tuesday.
He had previously given Mr Johnson the benefit of the doubt, he said.
When Mr Javid quit on Tuesday, a wave of resignations followed. Mr Johnson will now stand down in the autumn.
The event which triggered the prime minister's downfall, described by Mr Javid on Sunday as the "final trigger", was the suspension of MP Chris Pincher over sexual assault claims.
Mr Johnson had appointed Mr Pincher deputy chief whip - whose job it is to uphold discipline among fellow Tory MPs - in February, despite being made aware of earlier misconduct.
"It might sound a bit strange but I was listening to the sermon by this amazing man, Reverend Les Isaac - you know, he started Street Pastors," Mr Javid told the BBC's Sophie Raworth.
"I was listening to him talking about the importance of integrity in public life and, just focusing on that, I made up my mind.
"I went straight back to my office and drafted the resignation letter and went to see the prime minister later in the day."
Asked if he had co-ordinated his resignation with Rishi Sunak, who quit as chancellor minutes afterwards and - like Mr Javid - is now standing in the contest to replace Mr Johnson, the former health secretary said "not at all".
"Once you lose confidence in your boss, your prime minister, I don't think you can hide that," he added.
On his own ambition to replace Mr Johnson, he said he had the necessary experience and would come forward with a new Conservative economic plan.
He is promising tax cuts, arguing that without an economic uptick, funding for public services will suffer.
Asked about the years when he himself was non-domiciled for UK tax purposes, Mr Javid, who was first elected as an MP in 2010, says this was in the 2000s before he entered public life.
He says he had a job that was international and had lived abroad including in the US and Singapore. In 2009 he moved back to the UK and ever since then he has been tax resident and tax domiciled in the UK.
"Everything I've ever done when it comes to UK tax affairs has been properly consistent with UK tax," Mr Javid says.