LONDON — For weeks, Prime Minister Boris Johnson of Britain was a defiant holdout among Western leaders in refusing to lock down his country against the spread of the coronavirus. On Friday, he became the first of those leaders known to have contracted the disease.
Mr. Johnson’s diagnosis, confirmed in a test on Thursday, threatened to throw an already rattled British government into turmoil. Fears of a wider contagion grew, as two other senior officials disclosed that they, too, were infected.
And with the heir to the throne, Prince Charles, saying this week that he had fallen ill with the virus, Britain faced the alarming prospect of having to confront its greatest crisis since World War II with several of its leading figures in quarantine.
Mr. Johnson, 55, insisted he would not relinquish his duties. In a remarkable two-minute video posted on Twitter, he used his own case as a sort of teachable moment for the country, appealing to people to work from home and comply with the more drastic social distancing measures he put in place Monday.
“I’ve developed mild symptoms of the coronavirus,” said Mr. Johnson, looking wan and speaking with a rasp in his voice. “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.”
But a critical member of his cabinet, Matt Hancock, the health secretary, also tested positive, meaning that the two people most directly responsible for dealing with the virus are now afflicted with it.
The government’s chief medical adviser, Chris Whitty, also reported symptoms of the virus and said he was isolating himself. There are fears that other officials who have been in meetings with Mr. Johnson could also have been exposed.
If Mr. Johnson becomes incapacitated, his duties would be taken over by the foreign secretary, Dominic Raab, who has tested negative for the virus. It is a head-spinning turn of events for a government that, just two weeks ago, was brimming with confidence after a landslide election victory in December.
Other world leaders, including Chancellor Angela Merkel of Germany and Prime Minister Justin Trudeau of Canada, have put themselves in isolation as a precaution in recent days. But no Western country has seen the virus threaten its entire political establishment as swiftly as Britain has in the last week.
It was only Wednesday that Buckingham Palace gave the stunning news about Prince Charles, the 71-year-old eldest son of Queen Elizabeth II. He met with Mr. Johnson on March 11 and with his 93-year-old mother on March 12, a day before he might have been infectious, according to medical advisers.
Mr. Johnson got well wishes from one political ally, President Trump. The two men spoke by phone on Friday, according to Downing Street, and Mr. Trump wished the prime minister a “speedy recovery.”
Until this week, Mr. Johnson had taken a decidedly more nonchalant approach to the virus than other European leaders. At a news conference in early March, he described visiting a hospital where he said there were coronavirus patients.
“I shook hands with everybody, you’ll be pleased to know,” he said, “and I continue to shake hands.”
Later, the prime minister balked at forcing pubs and restaurants to close their doors, even as he asked people to stop congregating in them, and he left open schools after France and Germany closed theirs.
Mr. Johnson insisted he was guided by his scientific and medical advisers, and by a strategy, grounded in behavioral science, that the government needed to roll out restrictive social distancing measures gradually and in the proper sequence to ensure that the public would comply with them.
Government officials further rattled the public by openly discussing the merits of “herd immunity,” with some briefings appearing to suggest that the virus would be allowed to pass through the population so that a large percentage would develop natural immunity, making them more resilient in the face of a second outbreak.
As the number of cases began to spike, outside experts warned that the country risked the same fate as Italy, where an explosion in the number of patients overwhelmed the health system. An influential report by Imperial College London warned that the death toll could be as high as 250,000.
Shaken by that projection, Mr. Johnson decided to change course last weekend. On Monday, he banned public meetings of more than two people and urged people to stay in their houses, except for trips for food, medicine, exercise and work, if their employers did not allow them to work from home.
On Friday, the country reported a death toll of 759, a one-day jump of 181 people.
In the last week, Mr. Johnson has emerged as a cheerful evangelist for social distancing, exhorting Britons to unite in a national campaign that carries distinct echoes of Britain’s stoic response to the Blitz during World War II.
In just two days, more than 600,000 people signed up as volunteers to help the National Health Service and 1.5 million elderly and vulnerable people, whom the government has urged to quarantine themselves for 12 weeks. On Thursday evening, tens of thousands of Britons stood on balconies or at open windows, clapping for the nation’s doctors and nurses.
At 8 p.m., Mr. Johnson stepped out of his office in 10 Downing Street, the prime minister’s official residence, to take part in the public demonstration of appreciation. But he made a point of standing a healthy distance from the chancellor of the Exchequer, Rishi Sunak, who also took part.
Mr. Johnson hailed the spirit of the British people in his video, saying “we’re going to beat it, and we’re going to beat it together.”
Now, though, he faces the grinding reality of being a coronavirus patient. After he came down with a cough and a high temperature in the late afternoon on Thursday, he consulted Professor Whitty, the chief medical officer, and was tested for the virus. He received the positive result at about midnight.
Mr. Johnson moved from his office to the adjacent building, 11 Downing Street, where the chancellor, Mr. Sunak, normally works. This allows Mr. Johnson to live and work at the same address, since he already occupied the apartment above the chancellor’s office.
That office is equipped with video conference facilities and Mr. Johnson is working normally, a spokesman said. On Friday morning, he took part in a daily emergency cabinet meeting remotely from his new quarters. Mr. Johnson plans to stay in isolation for seven days, with his meals left at the door.
Downing Street gave no information about the whereabouts of Mr. Johnson’s partner, Carrie Symonds, who is pregnant with the couple’s first child. The couple announced their engagement last month. She is also in isolation, according to a photo she posted on social media.
Among the questions the government will face is how many people Mr. Johnson came into contact with over the last few days.
Many officials had stopped working in Downing Street, participating in meetings through conference calls. But a skeleton staff did still work in the building, and senior officials like Mr. Sunak and Mr. Hancock cycled through, appearing alongside Mr. Johnson at briefings there. Though lawmakers sat further from each other than normal in Parliament on Wednesday at Prime Minister’s Questions, Mr. Johnson was still reasonably close to Mr. Hancock and later to the home secretary, Priti Patel.
Mr. Johnson did not appear at the daily news conference on Thursday, at which Mr. Sunak rolled out the latest plan to protect workers who have lost wages because of the lockdown of the country. Mr. Sunak has not had symptoms of the virus, according to the BBC, and has not been tested.
In recent days, other people who work in Downing Street have begun to isolate themselves after displaying symptoms, but no contact tracing is taking place, officials said. Britain’s testing program has come under criticism in recent days as lagging that of other European countries.
Still, Mr. Johnson’s aides played down the risk to other senior cabinet ministers and officials who have come into contact with him, arguing that the government had observed the advice it offered to the public to keep a distance of two meters, or 6 feet, 6 inches, from other people wherever possible.
As he wrapped up his message to the British public from his new home for the next seven days, Mr. Johnson sounded every inch a convert to restrictive measures.
“The more effectively we all comply with those measures,” he said, “the faster our country will come through this epidemic, and the faster we’ll bounce back.”