Volkswagen in the US has been ordered to recall nearly 500,000 cars following charges by US regulators of making vehicles designed to evade government pollution controls.

Volkswagen designed software to meet clean-air standards during official emissions testing, but that turned off during normal operations, US and California regulators charged.

As a result, the diesel cars emit greater-than-allowed quantities of pollution linked to smog and various health ills.

"Using a defeat device in cars to evade clean air standards is illegal and a threat to public health," said Cynthia Giles, assistant administrator for the US Environmental Protection Agency.

Both the US Environmental Protection Agency (EPA) and the California Air Resources Board have launched investigations into the illegal actions.

The cars employed a sophisticated software algorithm to detect when the car was undergoing official emissions testing and turn on full emissions controls only on that time.

The mechanism meant that during normal operations, the cars could emit as much as 40 times the legal standard of nitrogen oxide, regulators said.

When EPA and California demanded an explanation this month, Volkswagen admitted that cars contained "defeat devices" meant to trick official tests, the EPA said.

"Our goal now is to ensure that the affected cars are brought into compliance, to dig more deeply into the extent and implications of Volkswagen's efforts to cheat on clean air rules, and to take appropriate further action," said Richard Corey, executive officer at the California Air Resources Board.

Volkswagen said it had received notice of an investigation "related to certain emissions compliance matters" from the EPA, the California board and the Justice Department.

"VW is cooperating with the investigation; we are unable to comment further at this time," it added.

A spokesman from the US Department of Justice referred the matter to the EPA and declined further comment.

The allegations cover 482,000 diesel models of Volkswagen Jetta, Beetle and Golf for 2009-2015 and the Audi A3 for the same years.

The action also affects the Volkswagen Passat for 2014-2015.

The EPA said it is "incumbent on Volkswagen to initiate the process that will fix the cars' emissions systems." The cars do not present a safety hazard, the agency said.

The potential fine for the offense is $37,500 (€33,160) per vehicle under the Clean Air Act, yielding a potential fine of as much as $18b (over €15b) according to US media reports.