A top German court ruled Tuesday that the country’s towns and cities can ban diesel vehicles in the interests of promoting cleaner air, a decision with vast potential implications for the automotive industry, the car-owning public and the environment.

The ruling, by Germany’s highest administrative court, clears the way for local authorities to prohibit millions of cars now on German roadways from entering congested areas where residents breathe air that routinely exceeds legal pollution limits. It does not, however, mandate such bans.

The decision was closely watched in a country with an enduring fervor for cars — engineering them, manufacturing them and driving them.

That love affair has been tainted in recent years by scandal. The 2015 revelation that Volkswagen cheated on emissions tests cast a particularly long shadow on an industry that employs some 800,000 Germans. 

Tuesday’s decision represents another critical blow for carmakers and for German authorities who had been seeking an excuse not to anger voters by instituting bans. 

At the same time, it was cheered by environmentalists and public health advocates, who said it gives lawmakers a badly needed tool for improving air quality. 

“This decision opens the door to clean air,” said Tim Butler, who leads an air-quality research group at the Institute for Advanced Sustainability Studies in Potsdam. “There’s going to be a huge problem in figuring out how to implement and enforce these bans. But ultimately, it’s the most effective way of cleaning the air, so it has to be done.”

Pollution from nitrogen dioxide — the lung-irritating gas that diesel vehicles emit in abundance — is above the European Union’s legal levels in about 70 German cities and towns. 

Across the E.U., nitrogen dioxide and fine-particle pollution are estimated to contribute to about 400,000 premature deaths a year — including nearly 75,000 in Germany.

Butler said that because diesel vehicles are the leading contributor to nitrogen dioxide emissions, banning them in heavily polluted areas makes sense.

Such prohibitions, however, are fiercely resisted by much of the German political and business establishment — as well as by car owners who fear that their vehicles will plummet in value if they are restricted in certain cities.

“Driving bans are the wrong measure,” Christian Lindner, leader of the pro-business Free Democrats, tweeted Tuesday. “For years politicians and administrators urged citizens and industries to purchase diesel cars. Forbidding their use is simultaneously callous expropriation and breach of promise.”

Successive German governments have incentivized the sale of diesel vehicles, which were long thought to be a better environmental choice than gasoline-powered cars because, although they produce more smog and soot, they emit less heat-trapping carbon.

But environmental groups and much of the rest of Europe have turned on diesel.

The court decision comes after Environmental Action Germany sued authorities in two western cities, Stuttgart and Düsseldorf, to force them to impose bans to stay within E.U. pollution limits.

The group won at the local level, but regional authorities appealed to the nation’s top court, in the eastern city of Leipzig.

Tuesday’s decision means that diesel bans in Stuttgart and Düsseldorf can go forward with modifications. It also sets a precedent for such bans elsewhere and adds to already growing pressure for Germany to act more resolutely to clean its air.

“The flooding of cities with poisonous diesel exhausts is over,” Jürgen Resch, head of Environmental Action Germany, said after the ruling was announced. “These cars don’t belong in our cities anymore.”

The European Commission recently gave the German government a final deadline for coming up with a plan to comply with E.U. clean-air rules. Federal authorities responded with proposals that included the possibility of making mass transit free in certain cities, although the wording was vague.

Chancellor Angela Merkel — known internationally as “the climate chancellor” for her efforts to rally global leaders around the challenge of rising carbon dioxide emissions — has opposed diesel bans. Her conservative Christian Democratic Union is considered a reliable ally of the car industry.

On Tuesday, Merkel sought to play down the court ruling. “We’re talking about individual cities in which more needs to be done, but not all of Germany and not all car owners,” she said.

The Volkswagen emissions scandal in 2015 has contributed to falling diesel sales. Before the company’s cheating became known, about half of all vehicles sold in Germany were diesel-powered. By the start of this year, that figure had fallen to a third. 

Still, about 15 million vehicles in Germany are diesel-powered, meaning any change to their status would have a wide-ranging impact. 

Particularly vulnerable to regulation are older diesel vehicles that are significantly dirtier than the newest models.

Across the continent, governments are cracking down on diesel in an effort to improve air quality. The mayors of Paris, Madrid and Athens have pledged to ban diesel vehicles in their city centers by 2025. France and Britain have said they will mandate a shift away from both diesel- and gas-powered vehicles by 2040, pressuring automakers to accelerate their transition to electric models. 

Car rules already exist in many European city centers, including Berlin, where vehicles can be driven in certain zones only if they have green badges to indicate low levels of harmful exhaust. Rather than excluding an entire category of cars, the badges ensure that any car emitting high levels of pollutants stays outside the zones. 

Some carmakers have responded to the push for cleaner air.

Volvo, based in Sweden although owned by a Chinese firm, has said that all of its new models will be either electric or hybrid by next year. Italian American manufacturer Fiat Chrysler, meanwhile, will stop producing diesel passenger vehicles by 2022, according to a report Sunday in the Financial Times

The vaunted German manufacturers, however, have been slow to transition, with their lineups still heavy on diesel and light on hybrid or electric offerings. 

Brian Murphy in Washington contributed to this report.