While dozens of countries across the world are under lockdown to contain the virus’s spread, in crowded and impoverished places like India, many fear that the measures could spark social unrest. Millions of people live in Indian slums, and staying at home for three weeks — as Mr. Modi has ordered — is a daunting prospect in such places, where dozens of family members often share a few rooms.

Migrant laborers have been protesting the lockdown across India. On Saturday, thousands came out to the streets in the southern state of Kerala, saying they had not eaten in days. The authorities urged them to disperse for their own safety, but they ignored the commands.

As of Sunday morning, just one of India’s 36 state and territorial governments, Uttar Pradesh, had made arrangements to bring migrants home, commissioning about 1,000 buses. On Saturday, migrants waited in lines miles long on the outskirts of Delhi to board a few buses, and the overwhelming majority were turned away.

But by Sunday afternoon, the central government had ordered states to reverse course and seal their borders, ordering migrants to stay where they are. The reversal added to the already confused rollout of the lockdown, which has prompted state government actions often at odds with the central government’s orders. The police, often confused, have resorted to violence.