* Court to rule on legality of bans on diesel vehicles
* Resale values could suffer, costly modifications may follow
* Similar bans looming in big cities in other countries (Adds details of demonstration, changes slug)
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 carmakers to pay for costly modifications.
Diesel-engine cars have been in the spotlight since Volkswagen admitted in 2015 to cheating U.S. exhaust tests, triggering a global backlash against emissions that contain particulate matter and nitrogen oxide (NOx) and are known to cause respiratory disease.
Environmental group DUH sued city authorities in Stuttgart, in Germany's carmaking heartland, and in Duesseldorf over levels of particulate matter exceeding European Union limits.
Local courts ordered cities to bar diesel cars that did not conform to the latest standards on days when pollution is heavy.
The German states have appealed against such rulings, leaving the country's highest federal administrative court in Leipzig to rule on whether they are legal.
The issue goes beyond Germany, Europe's largest economy and home to some of the continent's biggest carmakers.
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 court in Leipzig, 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 18 percent in January to just a third of new car sales from almost half before the VW scandal.
Analysts at Bernstein Research have said that diesel bans in Europe would hit French carmaker Peugeot hardest, followed by Renault.
Among German carmakers, Daimler's global fleet exposure to diesel was around 38 percent, BMW's 35 percent and VWs 26 percent, Bernstein said in a report from 2016.
Environmental groups say levels of particulate matter exceed the EU threshold in at least 90 German towns and cities.
Chancellor Angela Merkel's government, which has come under fire for its close ties to the car industry, agreed a deal with carmakers last year to overhaul engine management software on 5.3 million diesel cars to try to avert a ban.
But environmental groups have called software updates insufficient and have lobbied for cars applying the latest Euro-6 and older Euro-5 emissions standards to receive hardware updates of their exhaust treatment systems.
German auto safety group ADAC said that hardware retrofits of Euro-5 vehicles cost between 1,400 and 3,300 euros and can cut diesel pollution by up to 70 percent.
However, Evercore ISI has said retrofiting the German Euro-5 diesel fleet could cost up to 14.5 billion euros ($17.8 billion) 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.
Volkswagen chief Matthias Mueller caused consternation in Germany in December when he suggested that the government should start phasing out subsidies of diesel fuel worth about 8 billion euros a year in favour of investment in electric car technology. ($1 = 0.8140 euros) (Reporting by Edward Taylor, writing by Emma Thomasson; Editing by Jane Merriman and Keith Weir)