Gate Gourmet, the caterer whose sacking of staff prompted a walkout by British Airways workers, has failed to stop mass protests near its Heathrow plant.
The demonstrations have been emotional and vocal
It claimed that demonstrations on the grass verges by the road leading to the factory intimidated staff.
While the High Court ruled they can continue, a limit was put on the number of pickets outside the firm's doors.
The Transport and General Workers Union (T&G) was also made legally responsible for the pickets' behaviour.
'No clear winners'
Gate Gourmet sacked more than 600 staff last week in a working practices row, prompting a walkout by British Airways ground staff that paralysed flights and stranded thousands of travellers.
Since then, the T&G and the sacked staff have been staging daily demonstrations outside the entrance to Gate Gourmet's Heathrow headquarters and on a verge called Beacon Hill about 500 yards away.
Unions are fighting to get Gate Gourmet workers reinstated
Emotions have been running high and there have been complaints of intimidation, with police called in to investigate allegations that one worker was head-butted.
The BBC's Patrick Bartlett called Sunday's High Court ruling "complex", adding that there were "no clear winners".
The T&G will have to police the behaviour of pickets and stop any attempts at intimidation or harassment in or around the demonstrations, he said.
Should they fail to do that, then they would face legal consequences, our correspondent said.
Gate Gourmet was awarded an injunction by the High Court limiting the number of people that could picket outside its main entrance to six.
The injunction also named 17 people who have been accused of harassment and intimidation.
Brendan Gold, chief negotiator for the union, said he was very pleased with Mr Justice Fulford's decision because "he's made it clear that the vast majority of our members are picketing legally".
He warned, however, that the decision would require "careful consideration" and the T&G would have to monitor the demonstrations.
Andy Cook, Gate Gourmet's director of human resources, said that the company had not been looking to cut the size of the protests, only stop the minority engaged in harassment.
The T&G union has called for calm and restraint
"The judge has agreed with us in the ruling that harassment and intimidation has been occurring against our employees," Mr Cook said.
"This gives us an order we need to make sure that behaviour will stop."
The legal action comes as Gate Gourmet tries to get its services up and running again.
It said it still expects to provide hot meals for British Airways' long-haul flights on Monday.
Despite the move, Gate Gourmet's future is uncertain.
The company has been losing money on its UK operations, and said that it will call in administrators unless it reaches a more favourable new contract with British Airways by Tuesday.
Gate Gourmet is owned by US private equity firm Texas Pacific Group and has seen profits squeezed after the emergence of low-cost airlines changed the way carriers fed their passengers.
Many airlines stopped offering meals altogether, while others negotiated much tougher contracts, analysts said.