BERLIN — A nationalist, anti-immigration party performed strongly in a state election Sunday in the region where German Chancellor Angela Merkel has her political base, overtaking her conservatives to take second place amid discontent with her migrant policies.

The three-year-old Alternative for Germany, or AfD, won 20.8 percent of votes in the election for the state legislature in Mecklenburg-Western Pomerania. Merkel’s Christian Democrats polled 19 percent, their worst result yet in the state.

The center-left Social Democrats, who led the outgoing state government in a coalition with the conservatives, remained the strongest party with 30.6 percent support.

Economically weak Mecklenburg-Western Pomerania, in Germany’s northeastern corner, is home to 1.6 million of the country’s 80 million people and is a relative political lightweight. It is, however, the state where Merkel has her parliamentary constituency, and Sunday’s regional vote was the first of five before a national election expected next September.

National AfD leader Frauke Petry celebrated “a blow to Angela Merkel.” Local AfD leader Leif-Erik Holm told supporters: “Perhaps this is the beginning of the end of Angela Merkel’s chancellorship today.”

Merkel’s refugee policies were a prominent issue in the campaign for Sunday’s election, which came a year to the day after she decided to let in migrants who were waiting in Hungary to travel to Germany — setting off the peak of last year’s influx. Germany registered more than 1 million people as asylum-seekers last year.

New arrivals have slowed drastically this year, policies have been tightened and Mecklenburg is home to few foreigners. Still, New Year’s Eve robberies and sexual assaults in Germany blamed largely on foreigners, as well as two attacks in July carried out by asylum-seekers and claimed by the Islamic State group, have fed tensions.

Merkel has stuck to her insistence that “we will manage” the refugee crisis, and has also said that “sometimes you have to endure such controversies.”

“This result, and the strong performance of AfD, is bitter for many, for everyone in our party,” said Peter Tauber, her Christian Democrats’ general secretary.

He said the state government’s positive record took a back seat for many voters, “because among a recognizable part, there was an explicit wish to voice displeasure and protest, and we saw that particularly strongly in the discussion about refugees.”

Sunday’s result could make it more difficult for Merkel to bury a festering dispute with the Christian Social Union, the Bavarian arm of her conservative bloc, which has long criticized her decision to open the borders and advocated an annual cap on migrants.

CSU general secretary Andreas Scheuer said that “we feel vindicated in our course.”

Merkel has yet to say whether she will seek a fourth term next year, as is widely expected. While polls this year have shown her popularity slipping from stellar to merely solid, there is no obvious conservative alternative and her bloc is ahead nationally.

“She is, in people’s perception, personally responsible for the border opening, and she has to deal with that,” political science professor Karl-Rudolf Korte told ZDF television. “But she can deal with it — she has a year.”

Mecklenburg was the only one of Germany’s 16 states where the far-right National Democratic Party was represented in a state legislature, but it lost its seats on Sunday. Its support dropped below the 5 percent needed to keep them, with many supporters switching to AfD.

The state has been run for the past decade by the parties that currently govern Germany. Popular Social Democratic governor Erwin Sellering has governed with Merkel’s party as his junior partner. Both parties lost support compared with the last state election in 2011, when they polled 35.6 and 23 percent, respectively.

The opposition Left Party — once popular with protest voters — also lost support, slipping five points to 13.2 percent. The left-leaning Greens dropped just under 5 percent and lost their seats.

AfD is now represented in nine of Germany’s 16 state legislatures and hopes to enter the national Parliament next year. Still, it fell short Sunday of its aim of becoming the strongest party in Mecklenburg, and also didn’t match the 24.3 percent support it won in another eastern state, Saxony-Anhalt, in March.

There’s no realistic prospect at present of AfD going into government. Other parties won’t deal with it.

The next regional election is Sept. 18 in Berlin, where local issues are likely to play a stronger role.