Daimler, which owns the luxury car maker, has been under intense pressure from police and prosecutors.
Authorities are investigating the possible manipulation of diesel exhaust emissions in passenger cars.
A Daimler spokesman said the software fix, which will cost about 220m euros (Â£195m), was not linked to the police investigation.
He said the "voluntary service measure" was to cut nitrogen oxide pollution.
"The service actions involve no costs for the customers. The implementation of the measures will be starting in the next weeks," Daimler said.
The measures come after German MPs last week questioned Mercedes-Benz executives about emissions.
At the time the carmaker agreed with the transport ministry to undergo another round of emissions tests.
In May German police searched 11 offices of the carmaker as part of an investigation into possible fraudulent emissions data by employees.
A total of 23 prosecutors and 230 police officers took part in the search in the states of Baden-Wuerttemberg, Berlin, Lower Saxony and Saxony.

Gurpal Virdi, 56, of Hounslow, west London, was acquitted by the jury at Southwark Crown Court.
Mr Virdi had denied indecently assaulting a male prisoner and misconduct in public office.
The charges dated back to on or before 7 November 1986.
During the trial Mr Virdi accused the Metropolitan Police of bringing the criminal case against him as part of a 17-year campaign to "hound" him out of the force.
The retired detective claimed the police had tried to discredit him after he gave evidence to the Stephen Lawrence inquiry about racism within the police force.
He told jurors: "This is a typical reaction from a department that has hounded me since 1998, investigating me and following me around and bugging my phone.
Mr Virdi retired from the Metropolitan Police in 2012 after 30 years of service.
Three million Mercedes-Benz owners in Europe will be offered a software fix for their diesel cars.
[NEXT_CONCEPT]
A former Metropolitan Police officer has been found not guilty of sexually assaulting a teenage boy in the back of a police van nearly 30 years ago.