India's 1.3 billion people will go under "total lockdown" for 21 days to combat the spread of the coronavirus pandemic, Prime Minister Narendra Modi said Tuesday, sparking panic buying with shoppers clearing out shelves.

"From 12 midnight today (1830 GMT Tuesday), the entire country will be in lockdown, total lockdown," Modi said in a national television address to the world's second most-populous nation.

India has lagged behind other nations in the number of COVID-19 cases, but there has been a sharp increase in recent days to 519 infections, including 10 deaths, according to the government.

A raft of lockdown measures had already been brought in by individual states and territories -- including sealing borders and restricting movement to only essential services -- to try and prevent an explosion of cases that could overwhelm the fragile public health system.

Modi warned that Indians had to observe the lockdown if they wanted to stop the spread of the deadly virus.

People line up outside stores in Mumbai to buy groceries on March 24 following Prime Minister Modi's lockdown announcement People line up outside stores in Mumbai to buy groceries on March 24 following Prime Minister Modi's lockdown announcement Photo: AFP / Indranil MUKHERJEE

"This is a curfew... We will have to pay economic cost of this, but to save every family member, this is the responsibility of everyone -- the biggest priority," the prime minister added.

"If these 21 days are not managed, the country and your family will go back 21 years... I am not saying this as your prime minister, I am saying it as your fellow citizen, family member."

Under the order, people could face up to two years in jail and an unspecified financial penalty if they flout the rules.

People line up at a dairy shop to buy milk in New Delhi on March 24 People line up at a dairy shop to buy milk in New Delhi on March 24 Photo: AFP / Aishwarya KUMAR

Within minutes of Modi's speech announcing the world's largest lockdown, AFP reporters witnessed people rushing to stores to buy groceries.

A family watches Prime Minister Modi's address to the nation at their home in Amritsar A family watches Prime Minister Modi's address to the nation at their home in Amritsar Photo: AFP / NARINDER NANU

In India's capital New Delhi, some people in their pyjamas ran towards nearby shops despite heavy rain to stock up, while in the financial capital Mumbai, long lines of masked people formed outside pharmacies and supermarkets.

In Ghaziabad, a city in India's most populous state Uttar Pradesh, police patrolled streets and used loud megaphones to tell residents to stay indoors.

Following his speech, Modi tweeted: "THERE IS ABSOLUTELY NO NEED TO PANIC."

"Essential commodities, medicines etc. would be available. Centre and various state governments will work in close coordination to ensure this," he added.

Local media reported that state leaders would announce the timings of when people could buy essential items.

"This lockdown is needed," virologist Shahid Jameel of biomedical research charity Wellcome Trust/DBT India Alliance told AFP after the announcement. "If this is not done now we would be looking at six to eight weeks later, with many more deaths."

"But it's going to be very hard on the poor and vulnerable. I hope there is a plan in place. The devil is always in the details," he added.

All social, political, sports, entertainment, academic, cultural and religious gatherings would be banned, the order said.

All transport services including air, rail and road, would be suspended. A maximum of 20 people would be allowed to attend a funeral.

People working in essential services such as hospitals, police and media were exempted from the stay-at-home order, authorities added.

E-commerce giant Amazon, which has a big presence in India, said in a statement on its website that it would only sell "high priority" products to customers.

The South Asian nation has already banned incoming international flights, grounded domestic flights and shut sea and river ports.

Indian Railways -- one of the world's biggest networks carrying more than 20 million passengers daily -- has cancelled all services except suburban and goods trains.