The ruling came as the German car industry is still struggling to emerge from an ongoing global emissions scandal that forced Volkswagen to pay more than $26 billion in fines and plead guilty to federal fraud and conspiracy charges in the United States. The company admitted to manipulating pollution controls on vehicles so that they could pass laboratory emissions tests, even as the cars continued to far exceed pollution standards on the road.

In few cities is the country’s environmental schizophrenia more stark than Stuttgart, capital of the wealthy state of Baden-Württemberg.

The Daimler star was visible on Tuesday, but so were brightly lit electronic signs across the city that declared a “particulate-matter alarm” and urged residents to leave their cars at home.

On days like this, a yellowish cloud hangs over Stuttgart. Regional courts here and in Düsseldorf, two of 19 cities where the environmental organization is suing, had ruled that diesel bans were a viable way to bring down harmful and illegal levels of air pollution. Diesel engines emit small particles and nitrogen dioxide that have been linked to cancer and more than 12,000 of premature deaths in Germany, experts say. Local authorities appealed the rulings, but on Tuesday the Federal Administrative Court rejected those appeals.

Industry leaders were stunned. Daimler declined to comment, but other carmakers expressed bewilderment. Volkswagen “is unable to comprehend” the ruling, a company statement said. “It threatens to produce a regulatory hodgepodge in Germany, which is unsettling for millions of motorists.”

The Mechanical Engineering Industry Association, whose members include car-parts makers and other companies in the automotive supply chain, said in a statement that “driving bans for diesel vehicles are the wrong way to solve a problem that arises in very particular locations under very particular conditions.”