German carmakers have agreed with top politicians to cut harmful emissions by updating software in five million diesel vehicles.
New engine management software will improve emission filtering systems and cut toxic nitrogen oxide levels by 25-30%, the industry association VDA said.
The industry is under pressure since a diesel emissions scandal exposed cheating to manipulate test readings.
The deal was struck at a summit with top politicians in Berlin.
It was approved in Berlin by Daimler, BMW, Volkswagen and Opel, VDA said in a statement (in German).
Car firms are a crucial part of the German economy, providing more than 800,000 jobs.
Pressure to cut emissions increased last week, when a court in Stuttgart upheld a proposal to ban older diesel cars from the city.
It is the home city of Mercedes and Porsche, and one of Germany's pollution hotspots.
As the summit got under way, Greenpeace environmental activists unfurled a banner on the roof of the transport ministry saying "Welcome to Fort NOx [nitrogen oxide]".
The VDA said the software updates would be free for motorists and would be just as effective, in cutting NOx levels, as any bans on diesel cars in cities.
The diesel cars targeted will be those in the EU's Euro-5 category for car emissions (for new registrations from 1 January 2011) and some in the Euro-6 category (for new registrations from 1 September 2015).
Of the five million cars covered by the agreement, 2.5 million are Volkwagens.
BMW says the offer will cover 225,000 of its cars in the Euro-5 category.
BMW will also give a discount of up to €2,000 (£1,792; $2,373) to drivers who exchange an old Euro-4 category BMW when they buy a new diesel BMW, electric BMW or Mini. Ford has made a similar offer.
The VDA stressed that the software update would not reduce a car's efficiency or durability.
Greg Archer of the lobby group Transport and Environment called the software upgrade a "welcome stop-gap measure" but said it was "not a long-term solution to the air pollution crisis".
The BBC's Jenny Hill in Berlin says air pollution now regularly exceeds legal limits in many German cities. It is a headache for the mighty automotive industry and for German politicians, ahead of a 24 September general election.
But Germany is unlikely to commit to ending production of combustion-engine vehicles any time soon, our correspondent says.
France and the UK plan to ban sales of fossil-fuel vehicles from 2040.
But switching to a future of electric vehicles will be hugely expensive - not least because of the need for charging points everywhere.