The first judgment in what lawyers have said could be one of the world's largest ever environmental trials has ruled that Shell may have to compensate some communities for oil spills from their pipelines caused by criminals in the heavily polluted Niger delta.

The ruling at London's high court, following interpretations of Nigerian law by two retired Nigerian judges, may limit damages that Shell is expected to have to pay Niger delta villages devastated by two massive oil spills in 2008 and 2009, according to the company.

The case, which will be heard next May in London and is expected to last three months, centres on the rusting 55-year-old trans-Niger pipeline which passes through villages, fields and swamps in Ogoniland on its way to an oil terminal at Bonny.

In November 2008 it ruptured twice in a few days near the fishing village of Bodo, spilling thousands of gallons of oil, polluting fishing grounds, and destroying livelihoods. Estimates of how much oil was spilled range from a few thousand to over 250,000 barrels.

Shell's Nigerian subsidiary, SPDC, accepted responsibility and, after three years of talks, offered £30m to compensate nearly 15,000 people who had claimed damages. This was rejected by community leaders as inadequate. According to Shell, the communities claimed damages of around £300m.

The 15,000 villagers, represented in the high court by UK law firm Leigh Day, argued that oil companies like Shell had a legal duty to take reasonable care to protect their pipelines from vandalism. In the past Shell has blamed sabotage for most oil spilt along with vandals stealing oil for illegal refineries and argued the state has been responsible for security.

The judge found that the Nigerian Oil Pipelines Act does not hold pipeline operators responsible for damage caused by oil theft but he identified exceptions, for example if a company did not install surveillance or anti-tampering equipment, or if it knew the time and location of a planned attack by criminals and decided not to inform the police.

Leigh Day interpreted the ruling to mean that Shell could now be liable to compensate for illegal oil theft from its pipelines if it failed to take reasonable steps to protect its infrastructure.

"This is a highly significant judgment. For years, Shell has argued that they are only legally liable for oil spills that are caused by operational failure of their pipelines and that they have no liability for the devastation caused by bunkered [stolen] oil", said Martyn Day of Leigh Day.

"This judgment entirely undermines that defence and states in clear terms that Shell does have potential liability if it fails to take reasonable steps to protect its pipelines", he said.

Shell however, claimed a victory. "We hope the community will now direct their UK legal representatives to stop wasting even more time pursuing enormously exaggerated claims and consider sensible and fair compensation offers," said Mutiu Sunmonu, managing director of the Shell Petroleum Development Company of Nigeria Ltd.

"From the outset, we've accepted responsibility for the two deeply regrettable operational spills in Bodo. We want to compensate fairly and quickly those who have been genuinely affected and to clean up all areas where oil has been spilled from our facilities, including the many parts of Bodo which have been severely impacted by oil theft, illegal refining and sabotage activities," he said.

Leigh Day will argue next year that 1,000 hectares of mangroves have been destroyed by the spills and a further 5,000 hectares have been impacted. This represents the largest loss of mangrove habitat ever caused by an oil spill.

Audrey Gaughran, Amnesty International's director of global issues, said: "The court's message is clear – if you don't take adequate measures to protect your pipelines from tampering, you could be liable for the damages caused.

"The ruling has opened the door for Nigerian claimants to demand compensation if oil leaks were a result of sabotage or theft – if the sabotage or theft was due to "neglect on the part of the [licence] holder or his agents, servants or workmen to protect, maintain or repair any work structure or thing", she said

The Niger delta is one of the most polluted regions in the world, with a legacy of millions of barrels spilt but not cleaned up since oil was found in the region in 1956.

According to Nigerian government figures, there were more than 7,000 spills between 1970 and 2000, and there are 2,000 official major spillage sites, many going back decades, with thousands of smaller spills still waiting to be cleared up.