German Chancellor Angela Merkel took some responsibility Monday for her party’s loss in Berlin vote, pledging there would be no repeat of last year's "chaotic" border opening to refugees.

Although she defended the "political and ethical" decision to open Germany’s borders for one million asylum seekers in attempts to avert a potential humanitarian catastrophe last year, Merkel admitted mistakes that she would avoid in future.

She said the government was "rather unprepared for the late summer of 2015."

Merkel's Christian Democratic Union came in second in Berlin, with 17.6 percent of the vote, its worst ever showing in the capital.

The Social Democrats won 22 percent of the vote. But due to losses for both parties in the Berlin vote they do not have enough support for a coalition government.

Second loss

The ruling CDU also lost support in elections two weeks ago in Mecklenburg-West Pomerania, while the heavily anti-immigration AfD won nearly 21 percent of the vote.

The anti-immigrant Alternative for Germany (AfD) gained from a popular backlash over Merkel's decision a year ago to keep German borders open for refugees. While finishing in fifth place, AfD won 14 percent of the votes, allowing the three-year-old party to enter its 10th regional assembly among Germany's 16 states.

FILE - Migrants wait for their registration in front of the Federal Office for Migration and Refugees at Berlin's Spandau district, Germany, Jan. 29, 2016.

Encouraged by its success in state elections, AfD said Monday it aims to enter the German parliament in federal elections next year.

Frankfurter Allgemeine Sonntagszeitung newspaper reported the gains by AfD indicates the party "doesn't just benefit from discontent in rural areas, but can establish itself ... in a city of millions that is known for its open lifestyle."