Mercedes-Benz C-Class and Vito models with diesel engines and a sports utility variant of the sedan, known as the GLC, were the main cars found to be at fault, the ministry said.

"The government will order 238,000 Daimler vehicles to be immediately recalled Germany-wide because of unauthorised defeat devices," the ministry said in a statement.

Germany can only order the recall of vehicles within its own borders, or of those vehicles issued with a pan-European road-worthiness certification via German authorities.

Daimler has pledged to work on removing the software and to cooperate with authorities, the ministry said.

Daimler Chief Executive Dieter Zetsche said on Monday that the carmaker had found a technical solution for updating the software on its vehicles, and he therefore expected the company would avoid a fine.

In a separate statement, Daimler confirmed the recall and said the question over the legality of the software would still need to be clarified.

Evercore ISI analyst Arndt Ellinghorst predicted the costs for the required software update for Daimler would be less than 100 million euros (88.3 million pounds).

"We don't see any evidence that Daimler was designing software to deliberately cheat on emission testing," he said. "Overall, this outcome should de-risk the stock."

(Reporting by Markus Wacket; Additional reporting by Andreas Cremer; Writing by Edward Taylor; Editing by Susan Fenton)