BERLIN—Volkswagen AG raced Wednesday to contain the widening scandal threatening Germany’s most important company, ousting its chief executive and pledging to prosecute those involved in a scheme to cheat U.S. auto-pollution tests.

CEO Martin Winterkorn’s resignation follows a calamitous few days after Friday’s disclosure by the U.S. Environmental Protection Agency that Europe’s biggest auto maker employed software on some VW and Audi diesel-powered cars to manipulate the results of routine emissions tests.

The...