Poland violated EU law by ordering large-scale logging in one of Europe's oldest woodlands, the Bialowieza forest, the European Court of Justice has ruled.
Bialowieza forest has been designated a Unesco World Heritage site and is home to Europe's largest herd of nearly extinct bison.
But Poland argued its decision to order a three-fold increase in logging was necessary to combat beetle infestation.
Poland says it will respect the ruling.
The court's decision is a defeat for the country's conservative-led government.
The ECJ said Poland had "failed to fulfil its obligations" in directives covering the habitats of animals and birds.
While the whole of the Bialowieza forest in Poland is protected under EU directives, only 17% of that area has been designated a national park where no logging takes place.
The court used particularly strong language to criticise Poland's argument that it was responding to a "constant spread" of infestation of spruce bark beetles. It said the infestation "was not identified in the slightest" as a threat in the government's 2015 management plan. The nationalist Law and Justice party (PiS) took office in late 2015.
The ECJ ruling was hailed by environmental activists. The group ClientEarth said the decision was for now only on paper and called for the government in Warsaw to scrap its original approval of logging.
A conciliatory response from Poland
By Adam Easton, BBC News Warsaw
The verdict was as expected in Warsaw. Poland's new Environment Minister, Henryk Kowalczyk, has said he will respect the court's ruling.
Poland's new Prime Minister, the German- and English-speaking former banker Mateusz Morawiecki, who was appointed in December, is a moderate who has taken a much more conciliatory line in an attempt to resolve Poland's list of disputes with Brussels over logging, judicial reform and accepting migrants.
One of his first announcements was to say that Poland would respect the court ruling on the Bialowieza forest. He then dismissed the man who ordered the logging increase, Jan Szyszko, in a reshuffle in January.
Election season has already started in Poland ahead of this year's local ballots. Mr Morawiecki was appointed in part to appeal to centrist voters.
Poland is also aware that it must engage constructively with Brussels if it is to improve its bargaining position during negotiations to decide the scale of the EU's next multi-annual budget. Poland is the biggest recipient of funds under the current EU budget.
The logging case is one of several key issues that have clouded relations between Poland's Law and Justice government and the EU.
Last December the EU launched unprecedented disciplinary measures against Warsaw over judicial reforms that "interfere significantly" in the judiciary.
Among the reforms was a bid to give the justice minister the power to remove court presidents from the communist era.
Poland's government has since sought to reach a compromise ahead of talks on the EU's long-term budget. Parliament in Warsaw voted to back changes to the reforms last week, removing the justice minister's power to get rid of the judges without seeking consultation.