Sean Gallup/Getty How Merkel and Europe came to embrace Erdoğan The refugee crisis changes EU’s tune on Turkey.

At the outbreak of the refugee crisis, Europe’s leaders insisted the region’s response be guided by the principles of solidarity and humanity. With no end to the refugee march in sight, those lofty aspirations are fading as the continent trades its modern European ideal for a 19th century German tactic: Realpolitik.

Only weeks ago, Turkish leader Recep Tayyip Erdoğan was on his way to achieving pariah status in Europe. His assaults on the basic tenets of democracy, from a free press to minority rights, earned him censure across the region.

Ankara’s surprise decision in July to abandon the peace process with Kurds by attacking rebel forces drew sharp criticism from Berlin and other capitals.

The outrage was short-lived.

Last week, top EU officials, including Commission President Jean-Claude Juncker and Council President Donald Tusk, hosted Erdoğan for dinner in Brussels. The purpose was not to upbraid the Turkish leader, but to plead for his help.

Erdoğan's transformation from pariah to partner underscores Europe’s desperation to find a quick solution to the refugee crisis. The EU remains deeply divided over how and whether to distribute the refugees among its members. The infrastructure for handling the influx in Germany, which has taken the lion’s share of refugees, is teetering on verge of collapse.

Turkey, the byway to Europe for the masses of Syrians, Iraqis and other refugees, is now viewed as the linchpin to bringing the crisis under control.

“Negotiating with Erdoğan is unavoidable,” said Thorsten Benner, Director of the Berlin-based Global Public Policy Institute.

The only question now is the price Europe is willing to pay to win his help. As so often in Europe’s recent past, the answer depends largely on Germany. Angela Merkel will visit Erdoğan Turkey on Sunday in the hopes of closing a deal, the contours of which emerged at this European summit.

On the table is a mix of financial aid, up to €3 billion to help Turkey pay for the refugees, as well as other measures, including visa liberalization for Turks traveling to the EU.

Berlin has long resisted relaxing visa requirements over concerns that doing so would unleash an influx of Turks into Germany, which already has a sizeable Turkish population.

Still, the chancellor may have little choice. She faces a swelling backlash at home, where local communities have been overwhelmed by the large numbers of refugees. With as about 10,000 new arrivals every day, she needs a solution soon.

German officials acknowledge privately that Erdoğan has succeeded in manipulating the situation into his favor. They accuse the Turkish leader of fomenting the crisis by not enforcing Turkey’s border and allowing conditions for the refugees to deteriorate to such an extent that they were encouraged to leave. Turkey has taken in about 2.5 million refugees since the Syrian crisis began. Many live below the poverty line.

So far, the only criticism of Merkel’s overtures toward Turkey has come from the ranks of the opposition. Leaders from the Left party and Greens say the timing of Merkel’s trip, just two weeks before Turkish elections, will allow Erdoğan to use the German leader for his campaign.

“To pursue a deal with a government that persecutes journalists, Kurds and unions is declaration of humanitarian bankruptcy,” Sahra Wagenknecht, a senior Left party official, said during a Bundestag debate Thursday, adding that Merkel should cancel her trip.

Other critics question what steps Turkey will take to secure its border and worry that an EU-sponsored crackdown could lead to human rights abuses.

Despite such warnings, a deal with Erdoğan is a price both European and German leaders are willing to pay if it helps ease the crisis.

“Every German politician would be thankful for any measures that slow down the flow,” Benner said.