Twitter has started blocking accounts in India following repeated official demands, as it seeks to defuse days of mounting tension with Prime Minister Narendra Modi’s government.

The US social media company said it had taken action on more than 500 accounts that had been flagged by the Ministry of Electronics and Information Technology. Some have been blocked in India but will remain available outside the country, while others have been permanently suspended.

But Twitter said it had not blocked the accounts of media outlets, journalists, activists or politicians, saying this would not be “consistent with Indian law [or] in keeping with our principles of defending protected speech and freedom of expression”.

The government has demanded that Twitter block hundreds of accounts tweeting about farmers’ protests against contentious new agricultural reforms that would open up the sector to greater private competition.

The company was criticised last week when it temporarily blocked a number of high-profile accounts amid a government clampdown on tweets about the weeks-long demonstrations.

However, the company’s decision to reopen the accounts within hours put it on a collision course with the government. The IT ministry threatened Twitter with consequences for violating Indian law, including fines or imprisonment of executives.

After months of peaceful sit-ins on New Delhi’s outskirts, the protests erupted into violence on a national holiday last month, resulting in the death of one protester.

Authorities in several states ruled by Modi’s Bharatiya Janata party have filed sedition cases against journalists and Shashi Tharoor, a high-profile opposition MP, for tweets about the death.

New Delhi has also criticised international celebrities, including the singer Rihanna and Greta Thunberg, the environmental campaigner, after they tweeted about the protests. The foreign ministry warned against “propaganda” disseminated by “vested interest groups”.

The stand-off comes amid wider concerns about the erosion of free speech in India, where the BJP has been accused of muzzling dissent and satire.

The BJP and its supporters have also begun actively promoting Koo, an Indian microblogging site, as a patriotic alternative to Twitter. The platform was launched last year at the height of the coronavirus pandemic and allows users to communicate with followers in eight Indian languages.

Many government officials, entities and high-profile BJP supporters have been promoting their new Koo accounts, including ministers Ravi Shankar Prasad, Piyush Goyal and departments run by the IT ministry.

“Hello folks, I am on Koo now, in case Twitter is shut in India for flouting our laws,” tweeted Smita Barooah, who helped co-ordinate the BJP’s social media campaigns in previous general elections.

The company won Modi’s Atmanirbhar Bharat, or “self-reliant India”, innovation challenge.