Two of Johnson's top aides in the fight against the virus — his health secretary and top medical adviser — also said they had the disease.
Johnson, 55, said he was tested Thursday after showing “mild symptoms": a temperature and a persistent cough.
“I’ve taken a test, that’s come out positive so I am working from home, I am self-isolating, and that’s entirely the right thing to do," Johnson said in a video message posted on his Twitter account.
“But 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.”
Health Secretary Matt Hancock was also confirmed to have the virus. Hancock, 41, tweeted: “Thankfully my symptoms are mild.”
Chris Whitty, who is chief medical officer for England, tweeted that he had “symptoms compatible with COVID-19” and would be self-isolating at home for a week.
Johnson, Hancock and Whitty have attended meetings of the government's COVID-19 crisis committee and appeared at the government's daily coronavirus press conferences.
Johnson is the highest-profile political leader to have contracted the virus, which has infected more than 500,000 people around the world.
Elsewhere, German Chancellor Angela Merkel, Danish Prime Minister Mette Frederiksen and South African President Cyril Ramaphosa have all been tested and found to be negative. Canadian Prime Minister Justin Trudeau self-isolated after his wife tested positive for COVID-19.
The British diagnoses are the latest evidence that no one — no matter how high-profile — is untouched by the global pandemic.
Politicians may be especially exposed, since they interact with large numbers of people. Britain's Parliament continued to meet as the virus spread, before it was eventually suspended on Wednesday — hours after Johnson held his regular question-and-answer session with lawmakers.
Parliamentary authorities are now facing questions about why they did not shut down sooner.
Susan Michie, professor of health psychology at University College London, said that those in government should “practice what they preach” about social distancing.
“Given the transmission routes of touching contaminated surfaces and breathing in virus-laden droplets, it should not come as a surprise to hear that the PM and health secretary have tested positive for coronavirus,” she said.
On Friday health officials said Britain had 14,579 confirmed cases of COVID-19, and 759 people have died — 181 deaths in 24 hours, the highest daily toll yet.
Britain's government is run from a series of interconnected buildings centered on 10 Downing St. and adjoining houses — a warren of rooms and narrow corridors that is both the prime minister's home and the workplace of hundreds of people.
Johnson's spokesman, James Slack, said the prime minister was self-isolating in his apartment, which is above 11 Downing St., and would have his meals left outside his door by staff.
"For now the prime minister’s symptoms are mild and he is continuing to do all of the same functions he was performing before. The only difference is he will now have to do that by teleconferencing," Slack said.
He would not say whether Johnson's 32-year-old fiancee, Carrie Symonds, who is pregnant, was currently living in Downing St.
Slack said several other Downing St. staff are self-isolating but he did not know of any other confirmed cases.
The government said that if Johnson is unable to work, Foreign Secretary Dominic Raab will replace him.
For most people, the coronavirus causes mild or moderate symptoms, such as fever and cough that clear up in two to three weeks. But for others, especially older adults and people with existing health problems, the virus can cause more severe illness, including pneumonia, and sometimes death.
On Thursday evening, Johnson stood outside his front door to join in a national round of applause for health care workers. Slack said the prime minister was careful to observe social distancing rules while he did so, standing several meters away from Treasury chief Rishi Sunak, who also took part.
Earlier this week Prince Charles, the heir to the British throne, announced that he had tested positive for the virus. His mother, 93-year-old Queen Elizabeth II, is self-isolating at Windsor Castle as a precaution.
Buckingham Palace said Johnson and the Queen last met on March 11. The pair have held their weekly audience by phone for the past two weeks.
Johnson has been criticized by his opponents for his Conservative government’s initial reluctance to impose tough restrictions on movement and the economy to try to stem the spread of the virus.
Early this month, Johnson recounted shaking hands with medics treating coronavirus patients at a hospital and said “I continue to shake hands.”
The government’s initial advice was that people should wash their hands frequently. As the number of cases soared, that escalated to include the closure of schools, bars, restaurants and non-essential shops and a nationwide order for everyone but key workers to stay home.
Johnson spoke by phone Friday with U.S. President Donald Trump, who wished him a speedy recovery, the White House said.
Vice President Mike Pence said the administration sent Johnson “our very best wishes.”
“He is a great leader. The president admires him. We consider him a friend," Pence said on American news channel CNBC.
Johnson's political opponents also wished him well. Jeremy Corbyn, leader of the main opposition Labour Party, wished the prime minister a speedy recovery and relayed his hope that his family is “safe and healthy.”
Danica Kirka in London and Darlene Superville in Washington contributed to this story.
The Associated Press receives support for health and science coverage from the Howard Hughes Medical Institute’s Department of Science Education. The AP is solely responsible for all content.