STOCKHOLM — Sweden’s government is scrambling to contain the political fallout from a huge breach of confidential data, including the possible disclosure of the identities of undercover operatives, under the watch of a government contractor.

The breach was disclosed this month by the Swedish newspaper Dagens Nyheter, when it reported that Maria Agren, the former director general of the Swedish Transport Agency, had been fired in January for negligent handling of classified data.

The agency entered into an outsourcing agreement with IBM Sweden in April 2015, worth nearly $100 million, to manage vehicle registration and driver’s license databases.

But adequate safeguards were not adopted, and as a result, unauthorized personnel at IBM subsidiaries in Eastern Europe had access to vast troves of sensitive information, including details about bridges, roads, ports, the subway system in Stockholm and other infrastructure.