STOCKHOLM (AP) — Three Swedish center-right parties on Friday agreed to form a coalition government with the support of the Sweden Democrats, a once radical far-right group that has moved toward the mainstream but retains a hard line on immigration.

The agreement comes after a month of talks following Sept. 11 elections that gave the Sweden Democrats an unprecedented position of influence in Swedish politics with over 20% of the vote.

Opposition leader Ulf Kristersson told reporters that his conservative Moderate party would form a center-right coalition government with the Liberals and the Christian Democrats, but remain in “close collaboration” with the Sweden Democrats. The center-right coalition depends on the support of the Sweden Democrats to secure a majority in Parliament, putting the party in a position to influence government policy from the sidelines even without Cabinet seats.

The party was founded in the 1980s by people who had been active in right-wing extremist groups, including neo-Nazis. They toned down their rhetoric and expelled openly racist members under Jimmie Akesson, who took over the party in 2005. Since then they have grown from a marginal movement with less than 2% support to become Sweden’s second biggest party.

Their success in the Swedish election, followed two weeks later by the even stronger showing by the Brothers of Italy in the Italian election, underlined a decades-long trend of far-right parties making inroads in European politics.

Akesson, who doesn’t consider his party far-right, said he would have preferred Cabinet seats for the Sweden Democrats, but he supported the deal that would give his party influence over government policy, including on immigration and criminal justice.

“For us, it has been absolutely decisive that a shift in power must be a paradigm shift when it comes to immigration policy,” Akesson said, adding that Sweden’s rules on asylum should be no more generous than required by the European Union, of which Sweden has been a member since 1995.

Sweden along with Germany stood out in Europe for its generous welcome toward asylum-seekers from the Middle East and Africa until the migration crisis of 2015-2016 prompted stricter controls on immigration.

A rise in gang violence in neighborhoods dominated by immigrants has led to widespread calls for even tighter controls on immigration and tougher sentences and deportations for foreign citizens who commit crimes in Sweden, policies long espoused by the Sweden Democrats but emulated in recent years by parties both on the center-left and center-right.

Kristersson, who is expected to lead the next government, said his coalition and the Sweden Democrats had agreed to increase prison sentences for gang members, including those under 18, and introduce special visitation zones for police to crack down on crime.

“We will also carry out a thorough review of the entire penal code, with tougher penalties for violent and sexual crimes,” Kristersson said on Facebook.

Kristersson met Friday with the speaker of Parliament who tasked him with formally forming a Cabinet. A parliamentary vote on electing Kristersson as prime minister was scheduled for Monday.

Prime Minister Magdalena Andersson of the center-left Social Democrats continues to lead in a caretaker government capacity until a new government is formed. The Social Democratic Party, the dominant force in Swedish politics for most of the 20th century, has gradually lost support since the 1990s. It has been in power for the past eight years in unstable alliances with left-wing and centrist parties.

Commenting on the new deal on Facebook, Andersson pointed to the influence the Sweden Democrats would get over the new government, saying that “even if Ulf Kristersson becomes prime minister, it is Jimmie Akesson who rules.”

The change of government comes at a delicate time for Sweden, which abandoned a longstanding policy of military nonalignment and applied to join NATO together with neighboring Finland in response to Russia’s invasion of Ukraine. Their application met resistance from NATO member Turkey, which placed a series of demands on Stockholm in particular to crack down on exiled Kurdish groups who are critical of Turkish President Recep Tayyip Erdogan’s regime and whom Turkey accuses of terrorism.

Kristersson said his coalition stands behind an agreement that the outgoing Swedish government and Finland signed with Turkey at a NATO summit last summer.

“We will continue to work seamlessly with it, and we will do it together with the now outgoing government,” he said. “We will do everything we can within that agreement to get Sweden and Finland into NATO as soon as possible.”

___ Associated Press reporters Jan M. Olsen in Copenhagen and David Keyton in Stockholm contributed to this report.