* Court to rule on legality of bans on diesel vehicles
* Resale values could suffer and costly modifications follow
* Similar bans looming in big cities in other countries (Adds details from court, background)
LEIPZIG, Germany, Feb 22 (Reuters) - A German court will rule on Thursday whether major cities can ban heavily polluting diesel cars, potentially hitting the resale value of 15 million vehicles in Europe's largest car market and forcing automakers to pay for costly modifications.
There has been a global backlash against diesel-engine cars since Volkswagen admitted in 2015 to cheating U.S. 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, bans in the birthplace of the modern automobile would be a new blow for the car industry, and an embarrassment for Chancellor Angela Merkel's government, which has backed it.
Germany has long promoted diesel to help cut carbon dioxide emissions and meet climate change goals, but the Volkswagen (VW) scandal has pushed its carmakers to step up spending on electric cars, as well as investments into making diesel engines cleaner.
Local courts in Stuttgart and Duesseldorf ordered a ban on diesel cars that did not conform to the latest standards on days when pollution is heavy after environmental group DUH sued city authorities over poor air quality.
The affected German states have appealed against these rulings, leaving the country's highest federal administrative court in Leipzig to rule on whether they are legal. The DUH is also pursuing bans in many other German cities.
As proceedings got underway in Leipzig on Thursday, lawyers discussed whether the government would have to introduce a new way of labelling cars to enable authorities to enforce any bans.
Merkel's government, which has come under fire for its close ties to the car industry, has lobbied against bans, fearing they could anger millions of drivers and disrupt traffic in cities, with public transport not in a position to take up the slack.
Meanwhile, authorities in Paris, Madrid, Mexico City and Athens have said they plan to ban diesel vehicles from city centres by 2025, while the mayor of Copenhagen wants to ban new diesel cars from entering the city as soon as next year.
France and Britain will ban new petrol and diesel cars by 2040 in a shift to electric vehicles.
A small group of protesters from Greenpeace gathered outside the Leipzig court, with images of lungs painted on their chests and holding up signs reading "Clean Air Now".
"Because the government has failed to do anything for years about exhaust problems in the cities, judges have to decide today how residents will be protected from bad air," said Greenpeace transport spokesman Benjamin Stephan.
The threat of bans has prompted a big fall in sales of diesel cars in Germany, down to just a third of new car sales in January from almost half before the VW scandal.
Analysts at Bernstein Research have said diesel bans in Europe would hit French carmaker Peugeot hardest, followed by Renault. Among German manufacturers, Daimler and BMW have the biggest proportion of diesel cars in their fleet, well ahead of VW.
In an attempt to avert bans, Merkel's government agreed a deal with carmakers last year to overhaul engine management software on 5.3 million diesel cars as well as funding for cities to help cut emissions by taxis and buses.
"I hope that the ruling avoids a patchwork-quilt of driving bans," Matthias Wissmann, head of the influential VDA automakers lobby, told the Stuttgarter Zeitung newspaper.
Environmental groups have called software updates insufficient and have lobbied for cars applying the latest Euro-6 and older Euro-5 emissions standards to have their exhaust treatment systems upgraded.
Evercore ISI has said it could cost up to 14.5 billion euros ($17.8 billion) to retrofit Germany's Euro-5 diesel fleet, and as much as double that if the entire diesel fleet is affected.
"The consequence could be the allocation of several billion euros to an old fleet and a legacy technology, through retrofits, all at a time when the industry needs to utilize resources to stay relevant," Evercore analysts wrote.
VW chief Matthias Mueller caused consternation among German diesel drivers in December when he suggested the government should start phasing out subsidies on the fuel worth about 8 billion euros a year in favour of electric car investments. ($1 = 0.8140 euros) (Reporting by Edward Taylor, Writing by Emma Thomasson; Editing by Keith Weir and Mark Potter)