A row between farmers and racehorse trainers in the Yorkshire Dales town of Middleham has erupted following a decision by the trainers to erect a fence to prevent sheep wandering across the gallops.

Middleham Trainers’ Association put the fence up in May following a series of near misses with sheep, and an incident last year in which a horse and rider were injured when sheep walked in front of a string of horses.

But the 15 trainers who use the famous North Yorkshire gallops put up the fence without planning permission, and have now been told to take it down after a local farmer complained. A stand-off has ensued, with some of the trainers threatening to leave the moor if the fence goes.

Leading northern trainer Mark Johnston said it made “no sense” for sheep worth £50 to be allowed to endanger horses worth millions. “We are responsible for 115 employees, we put £2.5m into the local economy and we can’t take those sort of risks,” he said.

Mr Johnston added that he had “reluctantly” applied for permission to build his own private, all-weather gallops on a nearby farm – a move which would take over 200 horses off the moor and drastically reduce the annual fee of £30,000 which the trainers pay to the town council to use the gallops.

But local farmer Rodney Tennant – one of several “gaitowners” with ancient rights to graze sheep on the moor – claims the blue plastic fence breaches locals’ rights and is demanding it be taken down.

“The trainers have annexed a huge section of the moor,” he said. “My solicitor has said this was unlawful and has written to advise them as much.”

A spokeswoman for Middleham Town Council confirmed that the trainers had submitted a retrospective application to DEFRA for the fence, but had been ordered to remove it pending the outcome.

“We’re trying to arrange a meeting between the trainers and Mr Tennant to try to resolve the matter,” she said. “We don’t want the trainers to leave the moor. They are important to the local economy and we need to get everyone together to sort this out.”