Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A nationalist anti-migration party powered into three German state legislatures in elections held Sunday amid divisions over Chancellor Angela Merkel's liberal approach to the refugee crisis.

Merkel's conservatives lost to center-left rivals in two states they had hoped to win.

Frauke Petry, chairwoman of the Alternative for Germany party, at an AfD gathering Sunday in Berlin after state elections in the German federal states of Baden-Wuerttemberg, Rhineland-Palatinate and Saxony-Anhalt. Michael Sohn / AP

The elections in the prosperous southwestern state of Baden-Wuerttemberg, neighboring Rhineland-Palatinate and relatively poor Saxony-Anhalt in the ex-communist east were the first major political test since Germany registered nearly 1.1 million people as asylum-seekers last year.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The three-year-old Alternative for Germany, or AfD — which has campaigned against Merkel's open-borders approach — easily entered all three legislatures.

AfD won 15.1 percent of the vote in Baden-Wuerttemberg and 12.6 percent in Rhineland-Palatinate, official results showed. It finished second in Saxony-Anhalt with 24 percent, according to projections by ARD and ZDF television with most districts counted.

"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.

Supporters of the right-populist Alternative for Germany party celebrate Sunday in Stuttgart after state elections in the German federal states of Baden-Wuerttemberg, Rhineland-Palatinate and Saxony-Anhalt. AP

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

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

"The democratic center in our country has not become stronger, but smaller, and I think we must all take that seriously," said Vice Chancellor Sigmar Gabriel, the Social Democrats' leader.

Merkel's party kept its status as strongest party in Saxony-Anhalt. It had hoped to beat left-leaning Green governor Winfried Kretschmann in Baden-Wuerttemberg, a traditional stronghold that the CDU ran for decades until 2011. It also had hoped to oust Social Democrat governor Malu Dreyer from the governor's office in Rhineland-Palatinate.

However, the CDU finished several percentage points behind the popular incumbents' parties in both states and dropped 12 percentage points to a record-low result in Baden-Wuerttemberg, with 27 percent support. Its performance in Rhineland-Palatinate, with 31.8 percent, was also a record low.

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.