The Thai prime minister, Samak Sundaravej, must resign in the next 30 days after a court ruled today that he had breached the constitution by hosting four cookery shows after he took office.

The extraordinary decision of Thailand's constitutional court will throw the entire government into turmoil as Samak's cabinet will also have to step down once replacements have been nominated.

Thai politics have been paralysed for weeks by anti-government protesters whose street campaigns demanded the renowned gourmand quit on the grounds he was corrupt. Demonstrators occupied Samak's compound and the protests turned violent, invoking the declaration of a state emergency.

But in the end it was his cookery show that was Samak's undoing. The decision of the court's nine judges, who said that "his position as prime minister has ended", could provide a way out of the current crisis as Samak has become a lightning rod for the protesters' anger.

But even after the court's six-to-three majority verdict, Samak's party and political allies in the six-party coalition said they would nominate him as prime minister again. The constitution sanctions no penalty for the breach.

Samak, 73, had been hosting the television show "Tasting, Grumbling" for the past eight years, while he was the governor of Bangkok. He gave up in April, two months after he became prime minister.

The popular programme featured the prime minister cooking up traditional Thai recipes - pork leg in Coca-Cola is a favourite - before indulging in a ranting monologue on subjects of his choosing. The grumpy right-winger would often visit restaurants or food stalls offering cooking tips. His other preferred haunts were Bangkok's food markets, where he would cast an eye over the produce.

But the £270 that he received for transport and the purchase of the ingredients for each of the four shows filmed after he assumed office constituted his cultivating a business interest, according to today ruling.

Samak denied that he been employed by the show's producers, but the judges ruled that he had breached a clause in the constitution, which was rewritten after the 2006 military coup that ousted his predecessor, Thaksin Shinawatra.

In what is bound to be controversial interpretation, the judges said he had contravened a rule that barred ministers from holding outside business interests while in office. The clause was designed to eliminate the conflicts of interest that bedevilled Thaksin's rule.