The Amsterdam District Court said the company should expect public protest about controversial business practices.
But it also gave Greenpeace a list of guidelines to ensure protests were “proportionate”.
Shell had sought a fine of 1.1m euros ($1.2m) for a breach of the ban.
But the Amsterdam court ruling said: “The judge took as a starting point that organisations such as Greenpeace are, in principle, free to carry out actions to let the public know about their point of view.”
“Future Greenpeace actions against Shell cannot be banned in advance provided that they remain in a certain framework,” the ruling added.
The framework included, for example, a time limit for protesters to occupy petrol stations.
The environmental campaigning group has organised several protests against Shell’s exploratory drilling in the Arctic.
In a recent protest on 14 September the group used bicycle locks to shut down pumps at more than 60 filling stations across the Netherlands.
“The mere fact that such an action causes nuisance or loss for the business targeted by the action – in this case Shell – does not makes such an action illegal,” the court said.
Greenpeace, which fears the company’s search for oil in the Arctic will devastate the environment, welcomed the verdict.
“The judge rejected the majority of this injunction and has reminded the company that civil disobedience is a right in democracies, even when its business is impacted,” Greenpeace International Executive Director Kumi Naidoo said in a statement.
Shell too said it was satisfied with the verdict.
“We are pleased that Greenpeace actions such as those of September 14 are now bound by strict conditions,” company spokesman Lukas Burgering said.