A mass felling of trees in one of the world’s most-polluted megacities has been halted by India’s top court, amid protests that their removal would strip Mumbai of a precious “green lung”.

Some 2,700 trees were to be cut down in India’s financial capital to make way for a depot for subway carriages in the city of nearly 20 million people.

But the felling angered locals, with Bollywood stars and residents joining regular demonstrations that grew over the weekend after workers started removing the trees at night.

More than two dozen activists who were arrested during weekend protests were all later released on bail, police said.

Following an emergency hearing called after petitions from activists, the supreme court said no more trees in the suburb of Aarey were to be felled until a court session on 21 October.

The date is also when crucial state elections are to be held, with the dispute taking on political significance.

The Shiv Sena, a powerful local ally of Narendra Modi’s ruling Bharatiya Janata party, has criticised the national government over the felling.

The subway project has sharply divided opinion and triggered a nationwide debate over conservation and need for development.

Supporters say Mumbai – ranked the world’s fourth most polluted megacity by the World Health Organization last year – badly needs new transport, citing its overburdened colonial-era railway system used by 7.5 million people every day.

Officials have defended the construction, saying only 30 hectares (74 acres) of the 1,300 that make up Aarey – a lush, green oasis close to the Sanjay Gandhi National Park – were being cleared.

Part of the dispute over the development is whether the area should fall under forest protection laws that cover the national park.

Police have barricaded all access points to Aarey, and on Monday stopped activists and journalists from entering the area.

An environmental activist, Puja Damadia, told Agence France-Presse that after the decision was handed down, residents reported “hearing chainsaw noises, which means the trees are still being cut”.

“We cannot go inside to even vet the information. Mumbai police has not been letting us organise protests anywhere in the city … despite procuring permissions in advance,” she said.