Mr Johnson said he developed mild symptoms over the past 24 hours, including a temperature and cough.
He is self-isolating in Downing Street but said he will "continue to lead the government's response via video-conference as we fight this virus".
In a video on his Twitter account, Mr Johnson, 55, said: "I'm working from home and self-isolating and that's entirely the right thing to do.
"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.
"I want to thank everybody involved and, of course, our amazing NHS staff."
✔@BorisJohnsonBoris Johnson #StayHomeSaveLivesOver the last 24 hours I have developed mild symptoms and tested positive for coronavirus. I am now self-isolating, but I will continue to lead the government’s response via video-conference as we fight this virus. Together we will beat this. #StayHomeSaveLives151K7:15 AM - Mar 27, 2020Twitter Ads info and privacy
End of Twitter post by @BorisJohnson
"So thank you to everybody who's doing what I'm doing, working from home to stop the spread of the virus from household to household," he added.
"That's the way we're going to win."
Mr Johnson was tested at No 10 by NHS staff, on the personal advice of England's chief medical officer, Prof Chris Whitty, Downing Street said.
He will still be in charge of the government's handling of the crisis, the statement added. Earlier this week, the prime minister's spokesman said if Mr Johnson was unwell and unable to work, Foreign Secretary Dominic Raab, as the first secretary of state, was the selected minister to stand in.
It is not known whether Mr Johnson will still be living with his fiancee Carrie Symonds, who is several months pregnant.
Pregnant women are advised to be particularly stringent when following social distancing advice, and minimise social contact for up to 12 weeks.
In his Twitter message, Mr Johnson also said "it was very moving last night to join in that national clap for the NHS".
Mr Johnson has been seen at several of the government's televised daily briefings in the past week, where he has appeared alongside senior medical officials to update the country on the virus.
Neither the PM's senior adviser Dominic Cummings nor Chancellor Rishi Sunak - who Mr Johnson has recently appeared alongside, while following social distancing advice - have symptoms or have been tested.