Boris Johnson and the health secretary, Matt Hancock, have tested positive for coronavirus, they revealed on Friday, leaving them each to work in isolation on leading the government’s efforts to tackle the pandemic.

Later on Friday England’s chief medical officer, Prof Chris Whitty, said he was self-isolating at home after experiencing symptoms compatible with Covid-19.

The prime minister, who is 55, will self-isolate for seven days in his flat above No 11 Downing Street after announcing that he had mild symptoms of a cough and temperature.

Johnson received the result at midnight, just hours after he was seen outside the door of No 10 clapping in support of NHS workers, alongside the chancellor, Rishi Sunak.

Hancock, who has responsibility for the NHS, said he would self-isolate until next Thursday. Whitty, who has not taken a test, said he would “be continuing to advise the Government on the medical response to Coronavirus, supported by my deputies.”

Johnson and Hancock have been in repeated contact with senior political figures, including cabinet members, and advisers in the last few days. But despite the two men testing positive, no other ministers or advisers would be tested for the virus unless they showed symptoms, Downing Street said.

Asked whether Johnson and Hancock had been taking the same precautions they imposed on the rest of the country at the daily press briefing, Michael Gove said: “The fact that the virus is no respecter of individuals, whoever they are, is one of the reasons why we do need to have strict social distancing measures so that we can reduce the rate of infection and reduce the pressure on the NHS.”

And he told reporters: “People are tested if they are symptomatic and those members of the sort of central effort in helping to defeat the virus who do show symptoms are appropriately tested. I think you can tell from the fact that the three of us are here demonstrates that there are three of us who have not yet demonstrated any symptoms.”

It is unknown how Johnson contracted the illness but officials confirmed other people who worked in No 10 were self-isolating after having coronavirus symptoms.

Johnson posted a video on Friday morning on Twitter saying he had a temperature and a persistent cough. “I am working from home, I’m self-isolating, and that’s entirely the right thing to do,” he said.

In the video, which Johnson recorded himself on a mobile phone, he said: “Be in no doubt that I can continue thanks to the wizardry of modern technology to communicate with all my top team to lead the national fightback against coronavirus.”