Maryland has reached a multimillion-dollar settlement with Volkswagen AG and two of its affiliates for using devices in cars that violated the state's environmental laws.

Under the settlement announced Wednesday, the auto manufacturers will pay a $29.5 million penalty.

They also agreed to choose a Maryland-based port facility to provide support to Volkswagen operations valued at $4.5 million.

If the automakers don't meet that part of the agreement, they'll have to pay an additional $4.5 million.

The "defeat devices" installed in vehicles enabled them to pass emissions tests.

But under actual driving conditions, vehicles with the devices installed emitted up to 40 times the allowable limit of nitrogen oxide.

Maryland Secretary of the Environment Ben Grumbles says the settlement is a "silver lining" of the Volkswagen scandal. The state filed the lawsuit against Volkswagen in July 2016.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.