The restrictions came into force at midnight local time (18:30 GMT) and will be enforced for 21 days.
"There will be a total ban on venturing out of your homes," Mr Modi said in a televised address.
He appealed for people not to panic - but crowds quickly mobbed stores in the capital, Delhi, and other cities.
Correspondents say it is not clear how - or even if - people will now be allowed out to buy food and other essentials.
The new measures follow a sharp increase in cases in recent days. There have been 519 confirmed cases across India and 10 reported deaths.
India - which has a population of 1.3bn - joins a growing list of countries that have imposed similar measures.
Nearly 400,000 people have tested positive for the virus worldwide, and around 17,000 have died.
"The entire country will be in lockdown, total lockdown," Mr Modi said on Tuesday.
He added: "To save India, to save its every citizen, you, your family... every street, every neighbourhood is being put under lockdown."
Mr Modi warned that if India does not "handle these 21 days well, then our country... will go backwards by 21 years".
"This is a curfew," he said. "We will have to pay the economic cost of this but [it] is the responsibility of everyone."