Sweden’s Prime Minister Stefan Lofven, Dec, 2, 2014
Sweden’s Prime Minister Stefan Lofven speaks during a news conference at the Chancellery in Stockholm Dec. 2, 2014. Reuters/Pontus Lundahl/TT News Agency

(Reuters) -- Sweden’s mainstream parties reached a deal Saturday that will allow the minority center-left government to remain in office and sideline the anti-immigration Sweden Democrats, who hold the balance of power in Parliament. The country’s normally stable politics were thrown into turmoil in December when Prime Minister Stefan Lofven said he would call a snap election in March after his budget was voted down by the center-right opposition and the Sweden Democrats.

“Sweden has a tradition of solving difficult questions,” Lofven said. “I am happy we have reached a deal that means that Sweden can be governed.”

The deal between the center-left Social Democrats and Green coalition and the four-party center-right Alliance means Lofven will have to follow the opposition’s budget next year, although he can make some changes in the spring.

The Alliance will abstain from voting against the government’s budgets from spring onward. The snap elections, which had been due to take place March 22, have been canceled.

Under the deal, lasting until 2022, the two blocs have also agreed to coordinate policy on pensions, defense and energy.

“It means that Sweden can be governed by the parties that have the biggest support among voters,” center-right Moderate Party acting leader Anna Kinberg Batra said.

Despite a tradition of minority governments, Sweden has not had snap elections since 1958, but the rise of the Sweden Democrats, reflecting gains made by the far-right across Europe in recent years, had led to parliamentary deadlock. The party, the country’s third-biggest after September’s general election, had threatened to bring down any government that did not curb rising immigration.

The center-left and center-right refused to have anything to do with the far-right, but their unwillingness to do a deal with each other left the Sweden Democrats with an effective veto. The Sweden Democrats wanted to make snap elections a referendum on Sweden’s generous immigration policies.

Recent opinion polls show that a new election would not have broken the political deadlock in Parliament with neither the center-right nor the center-left able to form a majority government -- and the Sweden Democrats continuing to hold the balance of power.

Some polls have shown Lofven’s Social Democrats, the biggest government party, gaining support, along with the Sweden Democrats. A poll by Novus Dec. 16, put support for the Sweden Democrats at 16 percent, up from 12.9 percent in September’s vote.

(Reporting by Daniel Dickson and Johan Sennero; Editing by Alistair Scrutton)