By Johan Ahlander and Johannes Hellstrom
STOCKHOLM (Reuters) - Swedish Prime Minister Stefan Lofven replaced two ministers on Thursday in a scandal over the leaking of sensitive data, trying to contain the damage and stave off an early election.
Faced with a political crisis over a botched IT outsourcing deal, Lofven sacrificed his interior and infrastructure ministers rather than step down or call a snap vote more than a year ahead of schedule.
But he retained Defence Minister Peter Hultqvist, defying opposition parties who had pressed for the removal of all three ministers.
The opposition parties said in a statement they would press ahead with a motion of no confidence in Hultqvist. If they win that vote, Lofven will have to remove him, which would leave the premier seriously weakened.
Although he insisted that he would not step down, Lofven finds himself struggling to preserve his minority left-green government in a fragmented political landscape where the far-right, anti-immigrant Sweden Democrats hold the balance of power.
However, he won some breathing space when the four-party opposition Alliance bloc said it would seek the confidence vote only after the summer break. Parliament is due to resume official business in September.
Referring to the threatened vote, Lofven told daily Dagens Nyheter: "We will handle that situation as well. I'm the country's prime minister and will handle that too."
Opposition Moderate Party leader Anna Kinberg Batra said on Twitter: "Welcome decision from Stefan Lofven that two ministers leave after the security crisis. But the reason for suspicion against Peter Hultqvist remains."
Lofven and his allies control 159 seats in parliament, while the Alliance holds 140 and the Sweden Democrats 47. Other parties refuse to work with them, but no one is capable of forming a majority without them.
(For a graphic on political stalemate http://tmsnrt.rs/2h5NdxU)
The scandal involves the handling of data under a 2015 outsourcing deal between the Swedish Transport Agency and IBM Sweden. Lofven admitted on Monday that his country and its citizens had been exposed to risks by potential leaks of sensitive information.
Among some of the details that could have been accessible outside Sweden were the registration numbers of most vehicles on land, air and sea.
Whistleblowers have raised concerns that information about vehicles used by the armed forces and the police may have ended up in the wrong hands. The identities of some security and military personnel could also have been at risk, according to reports, although no evidence has emerged that actual harm was caused.
Hultqvist has acknowledged knowing about the affair since early 2016. But his position is bolstered by the fact he is not responsible for the Transport Agency, and the army has said it took appropriate measures early on and that the scandal has not impacted its operations.
IBM Sweden says it never discusses its dealings with clients.
The Swedish crown was unperturbed, trading largely unchanged against the euro after initially strengthening somewhat.
"Financial markets have taken this in stride, and I think that will continue also going forward," said Robert Bergqvist, SEB chief economist.
"The combination of a strong Swedish economy, a strong balance sheet, and the economic-political framework gives us protection against these political events. But there could possibly be somewhat more nervousness in the financial markets if problems around the state budget arise, so we need to keep an eye on that."
Sweden has enjoyed an economic boom most countries in Europe would envy. Gross domestic product grew by 3.2 percent last year and is predicted to grow by 2.4 percent this year.
(Additional reporting by Johannes Hellstrom in Stockholm, writing by Gwladys Fouche; Editing by Mark Trevelyan)