Does prostitution count as "heavy physical work"? Will the presence of a brothel next to a through-road increase the accident rate? How many cubic metres of air are needed for two people to have sex safely?

Not questions a judge has to consider every day, but these are the conundrums courts in Austria have been mulling over lately in a farcical battle over a planning application from a pimp.

St Andrä im Lungau is a picturesque village nestled in a valley in a mountainous area of Salzburg. It boasts quaint houses, a lovely pub, a famous steam railway and now – after a bitter nine-year legal battle – a lemon yellow bordello called Villa Erotica.

In 2002 a former wrestler, Norbert Sendlhofer, decided the 770 inhabitants of St Andrä needed not another pub but a place to buy sex. He put in a planning application to turn an old hunting lodge on the outskirts of the village into what locals quickly called a den of iniquity.

The mayor was horrified and, backed by his outraged constituents, began a campaign to thwart Sendlhofer's ambition, exhorting every law they could think of to stop the sex trade from coming to St Andrä. Commercial law, property law, criminal law, health and safety regulations – all were tried. Prostitution is legal in Austria, but they were determined to keep their village prostitute-free.

For years, planning experts and officials trooped in and out of Villa Erotica, asking questions and taking measurements. The Austrian newspaper Der Standard reported that in July 2005 St Andrä authorities informed Sendlhofer that his application had been rejected on the advice of the local public health officer, who claimed there were "inadequate sanitary facilities" for "business transactions which specifically deal with the excretion of bodily fluids".

That wasn't all: an operation like Villa Erotica could "impair the moral, religious and psychological" life of the village" said the rejection letter, according to Der Standard.

Sendlhofer was undeterred. He installed new showers to meet hygiene requirements, and when the council criticised the quality of drinking water at Villa Erotica, he dug new wells.

In 2007, increasingly desperate to find reasons to reject the application, one resourceful local hit upon the notion that prostitution could be classed as "physical labour" and as such was subject to special health and safety regulations.

A medical expert wrote a report for the council, claiming "prostitution is heavy physical work which is carried out in all possible postures". They reached the conclusion that the ceilings of Villa Erotica were too low for suitable work spaces for prostitution and there were too few cubic metres of air to give sex workers the "volume of air" needed to carry out their duties.

The ploy worked – briefly. Alas for the burghers of St Andrä, a higher court in Salzburg last year quashed the verdict and Villa Erotica was given the green light. Ironically, it was the brothel's red light which caused its next problem: apparently, you need special planning permission to install unusual external lighting.

When the brothel finally opened for business recently, Sendlhofer had the last laugh. The fuss of the previous nine years resulted in enormous press interest, and he was able to goad his opponents by telling TV cameras there was "no better location in the whole of Austria" for Villa Erotica.