The court ruled that, since the 2010, the UK had failed to tackle the problem of toxic NO2 gas emissions in the shortest possible time.
The EU court has continued to oversee the case because proceedings started before Brexit.
The government believes the judgement is unfair and is mulling its next move.
The UK has been ordered to pay costs to the European Commission; the amount could run to millions of pounds.
Nitrogen dioxide (NO2) is emitted by gas heating boilers and cars, and the main hotspots are next to busy city streets.
That’s why the government has told 61 councils to clean up pollution on a local level.
Ministers admitted to the court that pollution limits had been breached, but they argued that other nations had broken limits too – indeed the UK was backed by Germany in this case.
The government laid part of the blame on the emissions test scandal, in which car makers cheated measurements of NO2 produced by their vehicles.
The court news comes soon after a coroner confirmed that the UK’s illegal levels of air pollution contributed to the death of nine-year-old Ella Adoo-Kissi-Debrah in south London.
Today’s ruling relates to failures that have also been the subject of successful legal challenges. These have been brought by the campaign group ClientEarth against the UK government in domestic courts since 2011.
A government statement said a UK High Court judge previously found the approach in its 2017 NO2 plan to be sensible, rational and lawful.
But the EU judges said the UK hadn’t moved fast enough to protect people’s health.
Following today’s ruling, if the UK still fails to comply within a “reasonable” period, the European Commission could issue formal notice requiring the UK to remedy the situation.
If the UK fails again, the Commission could bring the matter before the court a second time.
If that happens, fines may be imposed – although it’s not clear legally whether the UK could be forced to pay, following Brexit.
In any future cases where the government has breached legal limits, the case would be dealt with by a new UK Office for Environmental Protection - although environmental campaigners claim that this watchdog is being weakened before it even becomes law.
The government's latest data shows that NO2 limits are being exceeded in 33 out of 43 air quality assessment zones.
Client Earth spokeswoman Katie Nield said: “The government has said that Brexit is an opportunity to take back control and to develop 'the most ambitious environmental programme of any country on Earth'.
“There is now a clear opportunity to not only establish stronger laws protecting people’s health and the environment.”
The group wants the UK to adopt World Health Organization (WHO) air quality guidelines, which are stronger than EU rules.
A government spokesperson said: “We are considering this judgment from the European Court of Justice. We continue to work at pace to deliver our ambitious NO2 Plan and our 2019 Clean Air Strategy, which was praised by the WHO as ‘an example for the rest of the world to follow’.
“Air pollution at a national level has reduced significantly since 2010, and now we are out of the EU, we are continuing to deliver our £3.8bn air quality plan to tackle nitrogen dioxide exceedances in the shortest possible time.”
This is business….if you want a friend, buy a dog.