A judge says the case raises “important issues”.
Hull City Council wanted Greggs to provide sanitary facilities.
But lawyers for the council complained that moves by a Government department and another local authority were wrongly preventing bosses from exercising a power to require the bakery firm to provide them.
Mr Justice Kerr has ruled in Hull City Council’s favour after analysing evidence at a High Court hearing in Leeds.
Hull council took legal action after Newcastle City Council gave guidance relating to toilet provision in food outlets which was approved by the Department for Business, Innovation & Skills’ Better Regulation Delivery Office.
Officials said the Better Regulation Delivery Office’s approval decision meant that outlets like Greggs - where “simple takeaway food was sold” but some seating was provided for customers who preferred to stay - “need not provide” bathroom facilities.
Lawyers representing Newcastle council, the Department for Business, Innovation & Skills, and Greggs - argued that bathroom provision at food outlets should be based on a predominant trade test.
They said if “takeaway trade was predominant” food and drink would not “normally” be sold for consumption on the premises - and outlet owners should not be required to provide toilet facilities.
Hull council said that approach could not be right.
And officials said such an interpretation gave the two Greggs’ bakeries in Hull an “unlawful and unfair” commercial advantage.
Mr Justice Kerr said Hull council’s claim was “well-founded” and the advice given by Newcastle council “flawed”.
He said he would quash the Better Regulation Delivery Office’s decision to approve Newcastle council’s guidance.
“The construction adopted by Newcastle is completely unsustainable,” said the judge.
“It is obvious that if a person sits down in a Greggs outlet at the seats provided and proceeds to eat a pasty and a fizzy drink just purchased at the counter for that purpose, that is a normal use of the premises.
“The fact that most customers take away their purchases and those who stay do not normally stay long, does not change that.
“The construction which looks to the predominant type of trade (sit-down or take-away) is obviously wrong ... It would mean that a cafe with, say, 25 tables, which also does a roaring take-away trade, doing more business for off-site than on-site consumption, could not be required to install toilets for those brave enough to sit down for a drink.”
He said: “The case raises difficult and important issues arising from a novel statutory method of local authority regulation.”