After a series of shock defeats to the anti-mass migration AfD party, German Chancellor Angela Merkel has promised to “stop illegal immigration” and send failed asylum seekers back to their home nations.

“We want to stop illegal immigration while living up to our humanitarian responsibilities,” Mrs. Merkel said after talks in Vienna with counterparts from along the Balkan migrant route.

In February, Germany accused Pakistan, as well as North and West African countries, of refusing to take back failed asylum applicants.

“It is necessary to get agreements with third countries, especially in Africa but also Pakistan and Afghanistan… so that it becomes clear that those with no right to stay in Europe can go back to their home countries,” Mrs. Merkel told reporters this weekend, DW reports.

Hundreds of thousands of Middle Eastern migrants began to flood countries along the Balkan route last year, soon after Mrs. Merkel unexpectedly suspended European Union (EU) border rules and “invited” “no upper limit” of migrants to Germany.

The anti-mass migration Alternative for Deutschland (AfD) party has recently surged in the polls, even overtaking the Chancellor’s Christian Democratic Union (CDU) in the state election in her hometown. The CDU also had their worst election result ever in Berlin just over a week ago.

Two days after that result, the Chancellor finally admitted her policies during the migrant crisis were wrong, insisting that she wished to “go back in time to be better prepared”.

Pressure has also been building on the Chancellor from Eastern and Central European nations affected by the migrant crisis, many of which have little history of mass migration and populations that largely do not support multiculturalism.

Hungary, Macedonia, Slovakia, Slovenia, and Austria have begun closing off their borders with fences and increased security. A deal with Turkey has cut the number of boats arriving in Greece in exchange for billions in aid and the promise of visa-free travel for Turks in the EU.

Following Mrs. Merkel’s comments at the conference in Vienna, European Council President Donald Tusk also appeared to take a dig at her policies. “Since the first days of the migration crisis, I have had no doubt that the main key to its resolution is restoring effective control of the EU’s external borders,” he said.

Austrian Chancellor Christian Kern added: “The redistribution issue was discussed, but I am convinced that we will make progress on that when the first two things are solved, namely building up border protection [and] building appropriate support structures in countries of origin.”

Many of the migrants still arriving have become trapped in Greece, unable to move up to the prosperous welfare states of Northern Europe. Earlier in the day, the Greek Prime Minister Alexis Tsipras slammed the EU for moving at a “snail’s pace” to relocate migrants.