European nations once friendly to refugees abruptly yanked their welcome mats Thursday, as Germany considered slashing its benefits and Croatia announced it was closing most of its road links with Serbia “until further notice.”

The German measures would overhaul asylum codes to stem the massive flow of migrants into Europe, scaling back the generous policies that have made Germany a beacon for desperate war refugees and economic migrants pouring out of the Middle East, Africa and beyond.

In a 128-page draft law produced by the German Interior Ministry and obtained by The Washington Post, the government would speed asylum procedures, cut cash benefits, hasten deportations and punish those with false claims and phony paperwork.

The tough new measures, the draft bill states, are needed to cope with the huge influx of refugees into Germany, where 800,000 asylum applications were expected this year in a country with a population of 81 million.

In Croatia, meanwhile, leaders reversed themselves a day after they promised to greet asylum seekers with open arms — a greeting that stood in sharp contrast to a decision by neighboring Hungary to seal its frontier with razor wire and riot police.

Croatia’s decision to close roads crossing into Serbia raised the risk of pushing asylum seekers into the area’s fields and forests, which are littered with land mines from the Balkans wars in the 1990s.

The crush of refugees and migrants has shocked European leaders even as they struggle to find a common strategy to deal with their biggest humanitarian crisis in decades.

The proposed German law would provide food and a ticket to return to the first European Union country the asylum seeker entered, instead of housing and cash benefits. That could mean far fewer people would win protection in Germany or elsewhere in Europe, since countries such as Hungary are generally declining to award refugee status.

In addition, asylum seekers deemed to be withholding vital information — such as their passports or proof of their country of origin — would be denied benefits. Asylum seekers also would need to remain in crowded reception centers for six months, rather than three, before earning the right to subsidized housing.

Those who failed to comply with orders to leave Germany could be subject to forced removal without advance notice.

It was unclear whether the proposed German law, which must be approved by Parliament before it can take effect, would continue to make exceptions for Syrians fleeing civil war.

“This draft counteracts the new German welcome culture,” said Karl Kopp, spokesman for the pro-refugee organization ProAsyl. “It contains a toughness and populism that is not acceptable.”

In announcing the closure of most roads into Serbia until further notice, the Croatian Interior Ministry said late Thursday that it took the step after more than 11,000 people arrived in a 24-hour period.

“Don’t come anymore here. Our capacities are full,” Croatian Interior Minister Ranko Ostojic said earlier in English near his nation’s border with Serbia. “If you want to save your life, please go to reception centers in Serbia or Macedonia or Greece.

“Anyone who is sending a message that this is an open door for the European Union, and that they can go to Germany and Slovenia . . . it’s a lie,” he said.

Croatia’s president, Kolinda Grabar-Kitarovic, asked her nation’s military to be ready to defend the border if necessary.

Croatia’s reversal came after hundreds of asylum seekers scuffled with Croatian riot police at the Tovarnik rail station near the Serbian border after waiting for hours in the late-summer heat with little food and water.

Panic erupted as people tried to rush onto buses that had arrived to take them to Zagreb, the Croatian capital.

One middle-aged man collapsed, according to journalists on the scene, while several women fainted.

After more buses appeared, the crowds subsided and tension eased.

Yet asylum seekers were surprised by what awaited down the road: Hundreds were taken to a “reception center for aliens” in Jezevo, a town on the outskirts of Zagreb, where more than 500 furious men were held behind high white walls topped with barbed wire.

“Get us out of here! We’re not animals! This isn’t a zoo!” they yelled from behind bars at gathered reporters.

“We’re dying in here,” Ahmed, 26, an architect from Damascus, Syria, said in an interview conducted by shouting across the detention center’s yard. “Why have they put us in this prison?

“Serbia was good to us. We thought Croatia would be good to us,” he said as men behind him shouted obscenities.

With the crisis building, and the European Union still divided over its response, European Council President Donald Tusk called an emergency meeting for Wednesday. For months, European leaders have been unable to agree on what to do with the hundreds of thousands of people flooding their borders.

So far the E.U. has agreed to accept and settle only 40,000 asylum seekers across 22 member nations. Plans for another 120,000 have been bitterly opposed by central and eastern European nations.

On Thursday, one of the officials who helped spark the onslaught resigned. Germany’s top migration official, Manfred Schmidt, stepped down for “personal reasons” less than a month after his agency posted a message on Twitter that had far-reaching consequences.

The announcement that Germany would no longer deport Syrian asylum seekers to the E.U. country they entered — often Greece or Italy — helped fuel fresh waves of refugees who saw Germany as opening its arms.

With Europe bitterly divided, bigger and richer countries are increasingly lashing out at poorer partners that have refused to take in many people.

“Germany is helping. The question is, who is helping Germany?” German Vice Chancellor Sigmar Gabriel asked in a video released Thursday.

He accused other countries of taking E.U. money, then “hiding in the bushes when they have to take responsibility.”

Hungary has so far taken the harshest measures to block the refugee tide, using tear gas, pepper spray and water cannons Wednesday to repel a crowd of migrants who threw stones and debris at police along the border fence.

“We don’t like the fence,” the Hungarian government’s chief spokesman, Zoltan Kovacs, said Thursday. “But it seems to be working to protect the country’s borders, to stop illegal migration. Obviously, we are going to continue with that: keeping the fence, protecting the fence by police.”

Hungarian authorities said the number of people crossing into their nation had all but dried up: 277 Wednesday, down from 9,380 Monday. Some of the few asylum seekers on Wednesday who made it into Hungary said that their applications were summarily denied and they were sent back into Serbia.

By Thursday, the camp along the Serbian-Hungarian border was quickly emptying as asylum seekers paid 20 euros apiece to get on buses that were ferrying them to the Croatian border. Children rode free.

“There is no wall you would not climb, no sea you wouldn’t cross if you are fleeing violence and terror. I believe we have a moral duty to offer them protection,” the top E.U. official in charge of refugees, Dmitris Avramopoulos, said after meetings Thursday in Budapest with senior Hungarian officials.

“The majority of people arriving in Europe are Syrians. They are people in genuine need of our protection,” he said.

Desperate to find beds for the night, Croatian authorities took hundreds of migrants to a three-star hotel in Zagreb that was repurposed as a makeshift shelter. There was confusion about whether asylum seekers would be able to travel onward to Western Europe.

Police issued two documents: one, an English-language “Leaving Order” that said they had entered Croatia illegally and had 30 days to leave. The other, in Croatian, was to be used if they claimed asylum in Croatia.

“Why are they stopping us now?” said Mohammed, 28, who used to work at a cellphone shop in Aleppo, Syria, and spent a night at the hotel in Zagreb. “We came to Europe because we saw the Germans on TV telling us they wanted us to come to Europe, saying, ‘Welcome, welcome.’ Now there are all these problems and all this confusion.”

But none of that was enough to deter Mohammed, who was last seen leading a group of asylum seekers to the main bus station.

Faiola reported from Berlin. Birnbaum reported from Brussels. Stephanie Kirchner in Berlin, Gergo Saling in Zagreb, Jodi Hilton in Horgos, Serbia, and Brian Murphy in Washington contributed to this report.

Read more:

Germany’s enthusiasm for refugees might not last. These maps explain why.

Refugees get a chance to wash and rest their weary soles in Budapest

Read The Post’s coverage on the global surge in migration