In a unanimous ruling, a panel of five Supreme Court judges, headed by the court's president Lord Neuberger, ordered "that the government must prepare and consult on new air quality plans for submission to the European Commission...No later than December 31, 2015".
NO2 is produced mainly by emissions from diesel vehicles and is linked to a range of respiratory illnesses.
The UK Environment Department said work had already been started on revised plans to meet EU targets on NO2.
Announcing the decision, Lord Carnwath said: "The new government, whatever its political complexion, should be left in no doubt as to the need for immediate action to address this issue."
More From This Section
ClientEarth lawyer Alan Andrews said: "This ruling will benefit everyone's health but particularly children, older people and those with existing health conditions like asthma and heart and lung conditions.
"The next government, regardless of the political party or parties which take power, is now legally bound to take urgent action on this public health crisis."
"It has always been the government's position to submit these plans before the end of this year. Meeting NO2 limits is a common challenge across Europe with 17 member states exceeding limits.