A top German court has ruled that it is still lawful for poultry and egg producers to kill unwanted male chicks.
The ruling, by Germany's Federal Administrative Court on Thursday, backs companies on a temporary basis until an alternative can be found.
Mass-culling of male chicks is common practice in industrialised farming around the world.
After being sexed, billions of the baby birds are killed shortly after birth - usually by grinding or gassing.
Officials say this means about 45 million male chicks die every year in Germany alone.
In 2013, the state of North Rhine-Westphalia issued a decree banning hatcheries from killing chicks. Two egg hatcheries in the state then appealed against this.
Paragraph one of Germany's Animal Welfare Act states that: "No-one shall inflict pain, suffering or harm on a pet without a reasonable cause."
A lower court ruled that killing for food production constituted "reasonable" grounds, leading to the latest high court challenge.
The German Minister for Agriculture, Julia Klöckner, has described the practice as "ethically unacceptable" and called for its ban.
But on Thursday the high court in Leipzig confirmed it will remain permissible until alternative methods of sex determination in eggs are introduced.
The ruling means that economic reasons alone do not constitute "reasonable" grounds - but stops short of immediately banning the practice.
Friedrich Ostendorff, a spokesman for the German Green party, said he was "surprised and disappointed" by the court's decision.
The mass-killing of male chicks is common practice in food production around the world.
For the billions of hens used in egg and poultry farming every year, a similar number of male chicks are killed shortly after birth.
Male chicks are viewed in the industry as commercially useless, because they grow more slowly than hens so are deemed unsuitable for meat production.
After sorting, the most common methods of killing involve asphyxiation by gassing or maceration in high-speed grinders.
The UK-based Royal Society for the Prevention of Cruelty to Animals (RSPCA) says that maceration can actually be considered more humane than gassing because, if carried out correctly, it kill chicks within a second while asphyxiation may take two minutes.
The mass-culling of male chicks has long been a focus of animal rights activists who say the practice is unethical.
Scientists in a number of countries have been trying to find a solution.
After years of research and millions in government funding, a German company called Seleggt started to sell the first "no kill" eggs on the market last year.
They developed a non-invasive way to determine chicken embryo sex, from about seven days after fertilisation, by extracting fluid and detecting hormones.
The method allows them to bring females to full maturity and discard males prior to hatching - turning them into high-quality animal feed.
The eggs, labelled Respeggt, are currently available in more than 200 shops in Germany, with hope the technology will become more widespread soon.