NEW DELHI — Indian authorities attempted Thursday to suppress a fresh round of nationwide protests against a new citizenship law, temporarily detaining thousands of people and suspending Internet service in several cities.

Police relied on a colonial-era measure to prohibit public gatherings in various parts of India. Protesters defied the ban and risked arrest to voice anger over the law, which they say is discriminatory and unconstitutional.

The measure creates an expedited path to citizenship for migrants who entered India illegally, provided they belong to any of six religions, including Hinduism, Buddhism and Christianity. It pointedly excludes Islam, the faith practiced by 200 million Indian citizens.

The government says the law is a humanitarian measure. But it has galvanized those who say Prime Minister Narendra Modi is seeking to transform an officially secular country into a Hindu nation where Muslims are effectively second-class citizens.

Protests have roiled India since the law was passed last week, and some have turned violent. They represent the most sustained show of opposition to Modi since he came to power in 2014.

Among those detained Thursday were high-profile political figures and academics, including Ramachandra Guha, a biographer of Mohandas Gandhi and one of India’s most distinguished historians.

“This is totally wrong,” he said in a video taken at a protest Thursday in Bangalore, just before he was hauled off by police. He called India’s leaders “paranoid” and “scared” of peaceful protesters.

Nilesh Jain, a lawyer and one of the organizers of Thursday’s protests in New Delhi, estimated that 5,000 people were detained for up to several hours. He spent part of the day in a stadium with hundreds of other protesters before being released. A police spokesman did not respond to requests for comment.

In an apparent first, authorities shut down mobile Internet access in parts of New Delhi on Thursday. A police order reviewed by The Washington Post instructed cellular companies to cut communications in five areas, including the locations of planned protests. India leads the world in the number of Internet shutdowns, which authorities say are a way to prevent violence and unrest.

Pavan Duggal, an attorney and cyberlaw expert, said he could not recall a previous instance when Internet service was curtailed in India’s capital. Resorting to such severe tactics to control protests is “counterproductive,” he said. By evening, mobile Internet was also cut in five other cities to quell potential unrest.

The Delhi police shuttered more than 15 metro stations and prevented vehicles from entering the city on several roads from the neighboring suburb of Gurgaon, leading to monumental traffic jams.

While such measures may have decreased the number of protesters, they did not stop the demonstrations. Bharat Tiwari, 50, a photographer, and his friend Ahmar Khan, 32, a writer, gathered at Jantar Mantar, a traditional protest site, where the crowd swelled to several thousand people.

The restrictions show “the government is desperate,” said Tiwari. He carried a poster with a tribute to Hindu-Muslim brotherhood.

In the financial capital of Mumbai, where the state government is controlled by a coalition of opposition parties, local authorities gave permission for a major demonstration. Thousands filled a park in the heart of the city and overflowed into nearby streets, chanting slogans favoring nationalism and opposing the Modi government. Some of the slogans likened Modi to Adolf Hitler.

Kameen Yaseen, a 32-year-old mechanic, attended the rally with more than 100 fellow residents of a predominantly Muslim neighborhood. He said it was the first time he had participated in a political demonstration.

Ever since the Modi government came to power, it has “made policies and laws that are targeting Muslims,” said Yaseen. “It’s better we stop this government from oppressing us before it’s too late.”

In Uttar Pradesh, India’s largest state and home to 200 million people, authorities announced a blanket ban on all protests Thursday. Police invoked the same measure used in New Delhi, a provision known as Section 144, to forbid gatherings of four or more people in the interest of public safety.

“Parents are advised to counsel their kids and ask them not to participate in any kind of protest, and if they do, police will take action against them,” said O.P Singh, the state’s director general of police.

Despite the warning, hundreds of protesters took to the streets Thursday afternoon in the Old City area of Lucknow, capital of Uttar Pradesh. They threw stones at officers, burned several vehicles and torched two police outposts. Police responded by firing tear gas and smoke grenades.

One person died from an apparent gunshot wound in the clash, according to a hospital official, but police denied firing any bullets. In the southern city of Mangalore, two people were killed by police during clashes with protesters, the Reuters news agency reported.

At Jantar Mantar in New Delhi, the crowds began to disperse by nightfall, but protesters vowed to return. Parivartan Pandya, 19, a university student, said it was his fourth demonstration since Sunday.

“This is an outburst against the last five years” of government policies, he said. “This movement will build up. We will continue to protest.”

Tania Dutta in New Delhi, Payal Mohta in Mumbai and Saurabh Sharma in Lucknow, India, contributed to this report.