An upstart German party stunned Chancellor Angela Merkel Sunday, winning three state elections by campaigning against the refugee policy which has flooded the European nation with more than 1 million immigrants.

The Alternative for Germany (AFD) had run against Merkel’s open border policy for refugees, and won support from defectors from Merkel’s party, the Christian Democratic Union (CDU) as well as other members of the democratic center. The election is the latest indication that the open borders policy is hurting Merkel, who 48 percent of Germans want to see resign, according to a poll.

"We are seeing above all in these elections that voters are turning away in large numbers from the big established parties and voting for our party," AFD leader Frauke Petry said.

They "expect us finally to be the opposition that there hasn't been in the German parliament and some state parliaments," she added.

The AFD did best in Saxony-Anhalt in what used to be East Germany, a poor state that has fewer Muslims than any of the 16 other German states. It garnered 24.4 percent of the vote here, coming in second behind the Christian Democratic Party and ahead of the historically strong Social Democratic Party, a member of the national coalition with Merkel’s CDU.

The AFD also did well in the affluent western provinces of Baden-Wurtenberg and Rhineland-Palatinate, where it won 10 percent of the vote.

The AFD will likely gain entry to the federal parliament in next year’s national elections, something that troubles some prominent Germans.

“Germany cannot afford to present a picture of a narrow-minded, even nationalistic, nation,” Gerd Weissenkirchen, former spokesman for the foreign affairs committee of the Bundestag, told FoxNews.com in a telephone interview. Weissenkirchen also warned that AFD’s xenophobia could spread from Muslims to other minority groups.

The AFD gains are a severe shift to the right as citizens voice displeasure over the strain a huge wave of refugees is putting on taxpayers, according to Professor Julius Schoeps, director of the Moses Mendelsohn Center in Potsdam.

“It’s part of a European trend,” Schoeps said. “France, the Netherlands, and now Germany are experiencing this phenomenon.”

There were uncomfortable results both for Merkel's conservative Christian Democratic Union and their partners in the national government, the center-left Social Democrats. The traditional rivals are Germany's two biggest parties.

Other parties won't share power with AFD, but its presence will complicate their coalition-building efforts.

In all three states, the results were set to leave the outgoing coalition governments without a majority — forcing regional leaders into what could be time-consuming negotiations with new, unusual partners. Merkel's CDU still has a long-shot chance of forming an untried three-way alliance to win the Baden-Wuerttemberg governor's office.

Germany's next national election is due in late 2017. While Sunday's results will likely generate new tensions, Merkel herself should be secure: she has put many state-level setbacks behind her in the past, and there's no long-term successor or figurehead for any rebellion in sight.

Merkel insisted last year that "we will manage" the challenge of integrating refugees. While her government has moved to tighten asylum rules, she still insists on a pan-European solution to the refugee crisis, ignoring demands from some conservative allies for a national cap on the number of refugees.

AFD's strong performance will boost its hopes of entering the national parliament next year. It entered five state legislatures and the European Parliament in its initial guise as a primarily anti-euro party before splitting and then rebounding in the refugee crisis.

The Associated Press contributed to this report