This is meant to limit emissions of particulate matter and nitrogen oxide (NOx), known to cause respiratory disease, after Volkswagen in 2015 admitted to cheating US exhaust tests.
A top German court ruled on Tuesday in favour of allowing major cities to ban heavily polluting diesel cars, a move likely to hit the value of 12 million vehicles in Europe's largest car market and force carmakers to pay for costly modifications.
There has been a global backlash against diesel-engine cars since Volkswagen admitted in 2015 to cheating US exhaust tests, meant to limit emissions of particulate matter and nitrogen oxide (NOx), known to cause respiratory disease.
While other countries are also considering restrictions on diesel cars, a ban in the birthplace of the modern automobile is a new blow for the car industry, and an embarrassment for Chancellor Angela Merkel's government, which opposes bans.
TRT World's Ira Spitzer reports from Berlin.
The ruling by the country's highest federal administrative court came after German states had appealed against bans imposed by local courts in Stuttgart and Duesseldorf in cases brought by environmental group DUH over poor air quality.
German broadcaster Deutsche Welle reported that the ruling does not determine whether the bans will be implemented, but rather whether German states, cities and communities have the right to impose them to maintain air pollution limits without needing federal legislation.
Merkel's government, which has come under fire for its close ties to the car industry, had lobbied against a ban, fearing it could anger millions of drivers and disrupt traffic in cities, with public transport not in a position to take up the slack.