NEW DELHI — The workers set out on foot in the wee hours of the morning for villages hundreds of miles away, walking along the roads they helped build and past apartment towers they helped raise.

Chandra Mohan, a 24-year-old plumber in a suburb of India’s capital, left at 3 a.m. on Friday. By midmorning, he had walked 28 miles, one bag on his back and another slung across his chest. He still had more than 600 miles to go to reach his home in the state of Bihar.

Mohan is one of thousands of people leaving India’s largest cities one footstep at a time, fleeing a pandemic in a historic exodus. There are no planes, no trains, no interstate buses and no taxis. So Mohan walked east with 17 other young men, all laborers like him. They were unsure of their route or where they would sleep or how they would eat, but one thing was certain: Without work, they cannot survive in the city.

“We’re doomed,” Mohan said bitterly. “If we don’t die of the disease, we’ll die of hunger.”

India has begun a 21-day nationwide lockdown — the biggest in the world — in a desperate bid to stop the coronavirus from spreading out of control in this densely populated nation of 1.3 billion people. There are more than 700 confirmed cases in India, a number that is rising rapidly. Nonessential businesses are shut, state borders are closed to regular traffic, and people have been asked to stay in their homes except to buy food or medicine.

The suspension of passenger trains, the backbone of India’s transportation system, was announced Sunday with nearly immediate effect. Then, on Tuesday, Indian Prime Minister Narendra Modi declared the all-India lockdown.

Three days later, Indians were adjusting to a starkly different reality. Reports of widespread harassment of citizens by police had eased even as bottlenecks persisted in the distribution of essential goods in some parts of the country.

The speed of the transportation shutdown meant that India’s tens of millions of internal migrants had no time to get home. Indian cities rely on a vast workforce drawn from the rest of the ­country, laborers who move in search of opportunity and often leave their families behind for months or years. They work construction, drive taxis, staff restaurants and much more, living frugally and returning home each year.

For such migrant workers, who are often employed in low-paid, precarious jobs, the measures are a double blow. The economic shock has vaporized their incomes while the transport restrictions eliminated their normal ways home.

The result has been a walking exodus of thousands of people. Precisely how many are on the move is not clear, but since the lockdown was declared, each day has brought fresh reports of migrants trying to get home. Some have managed to hitch rides on trucks, or jam themselves into crowded private buses.

The last time so many people were traveling long distances on foot was in 1947, during the bloody partition of the Indian Subcontinent, said Chinmay Tumbe, the author of a recent book on migration in India. When India became independent and Pakistan was created, millions of people fled to the other side of newly drawn borders. “Even then we had transport options,” Tumbe said. “There were trains running.”

There are already signs that workers are turning to smugglers in the hopes of getting home. Authorities found hundreds of people crammed into trucks and believe hundreds of others hid inside an empty freight car to move from one end of the country to the other, according to a local media report.

Rajiv Khandelwal is executive director of Aajeevika Bureau, an organization based in Rajasthan focused on migrant workers. His group has received “an avalanche” of distress calls in recent days, he said. Many callers are stranded at state borders, unable to cross and running out of food after losing their jobs.

“Everybody has a right to go home when so much fear and frenzy has been created,” Khandelwal said. “This is no way to condemn people on whose hard work these cities prosper.”

In its rush to institute a nationwide lockdown, India offered no formal help to poor migrants. That stands in sharp contrast to its treatment of citizens stranded abroad because of the pandemic: The government organized special flights to bring Indians home from China, Iran and Italy.

Arjun Kumar, 20, and his four cousins came to Delhi to work over the past year, earning $4.50 a day on construction sites. But there has been no work for days. Their home is more than 450 miles away in Basti, a district in the state of Uttar Pradesh. On Friday, they walked east under a light drizzle on roads emptied of traffic.

Kumar carried a purple shoulder bag printed with teddy bears and urged the group to keep moving. At least in their village, they won’t starve, he said. “Here in the city, who will feed us?”

Most of the people walking are men, many of them young, but there are also some families. Payal Kumar, 19, sat on the edge of a sidewalk Friday, using a scarf as a makeshift mask. She was barefoot; her only pair of sandals had broken as she walked. Her group’s water was gone, she was tired and had no idea how long it would take to reach their home 150 miles away.

Kumar was walking with her sister Divya and her sister’s in-laws. One of them, Anar Singh, 35, works as part of the housekeeping staff at a Radisson hotel. His employer told him to stop coming to work nine days ago when the hotel closed down. He says he has yet to receive his salary for the month. He had about $5 in his pocket.

The group carried bags containing a few items of clothing and some flatbreads to eat. They hoped to be able to shelter in a shop or market at night. “For now, we have to keep walking,” Singh said.

Near one of Delhi’s long-distance bus stations, migrants converged in the vain hope that some transport might be available. By midmorning, they numbered in the hundreds. Stick-wielding police officers began herding them down the road.

One officer stopped a group of migrants and used a loudspeaker to make an announcement. “You have to maintain a distance of at least one meter from each other,” he said. The weary crowd dutifully shuffled a bit apart. A good Samaritan pulled up and offered biscuits and tea from the back of a motorcycle.

Rajesh Mishra, 30, a painter who had been walking for four hours, listened to the officer’s speech. His home is 500 miles away in the city of Gorakhpur. “We’re stuck,” he said. “Either we stay and die, or leave and die.” Then he turned and joined the stream of people stretching into the distance.