BRUSSELS, April 4 - In early March, Europe's migration chief Dimitris Avramopoulos squelched through a muddy refugee camp on Greece's border with Macedonia and peered through the barbed-wire topped fence that stands between tens of thousands of migrants in Greece and richer countries that lie to the north.
"By building fences, by deploying barbed wire," he said, "it is not a solution."
But Avramopoulos has not always preached that message - and his changing views capture the tangle Europe has got itself into as more than a million migrants and refugees have floated in on Greek waters since the start of 2015.
In 2012, when he was Greek minister of defense, Greece built a fence and electronic surveillance system along its border with Turkey. The cement and barbed-wire barrier and nearly 2,000 extra guards were designed to stop a sharp rise in illegal immigrants.
The 62-year-old former diplomat was not directly involved in the project. But in 2013 he defended it, telling a news conference the wall had borne fruit. "The entry of illegal immigrants in Greece by this side has almost been eliminated," he said.
The official European response to Europe's migrant crisis - championed by German Chancellor Angela Merkel last August - is for member states to pull together and provide shelter for people, especially Syrians, fleeing war or persecution. But in reality, most members have failed to take their quotas of refugees and nearly a dozen have built barricades to try to keep both migrants and refugees out. The bloc is now trying to implement a deal which would see Turkey take back new arrivals.
Related: The most powerful images from the migrant crisis:
The European Union was founded in the ashes of World War Two, in part on a principle of freedom of movement among member states. But since the fall of the Berlin Wall, European countries have built or started 1,200 km (750 miles) of anti-immigrant fencing at a cost of at least 500 million euros ($570 million), a Reuters analysis of public data shows. That distance is almost 40 percent of the length of America's border with Mexico.
Many of these walls separate EU nations from states outside the bloc, but some are between EU states, including members of Europe's passport-free zone. Most of the building was started in 2015.
"Wherever there have been large numbers of migrants or refugees trying to enter the EU, this trend has been followed up by a fence," said Irem Arf, a researcher on European Migration at rights group Amnesty International.
For governments, fences seem like a simple solution. Building them is perfectly legal and countries have the right to control who enters their territory. Each new fence in Europe has sharply curbed the numbers of irregular immigrants on the route they blocked.
For at least one company, fences work. The firm which operates a tunnel between France and Britain says that since a major security upgrade around its French terminal last October, migrants have ceased to cause trouble.
"There have been no disruptions to services since mid October 2015, so we can say that the combination of the fence and the additional police presence has been highly effective," Eurotunnel spokesman John Keefe said.
But in the short term at least, they have not stopped people trying to come. Instead, they have diverted them, often to longer, more dangerous routes. And rights groups say some fences deny asylum-seekers the chance to seek shelter, even though European law states that everyone has the right to a fair and efficient asylum procedure.
Forced to find another way, migrants and refugees often turn to people-smugglers.
Greece's border fence was one of the first, and Avramopoulos still defends it. He says Greece built it to divert people towards official crossings where they could apply for asylum. Much of Greece's frontier with Turkey is delineated by a fast-flowing river, the Evros. But there is a 12 km stretch where people used to sneak through on land after making the river crossing in Turkey.
"The Evros river is a very dangerous river," Avramopoulos told Reuters in his upper floor office suite in February. "Hundreds of people had lost their lives there."
At least 19 people drowned in the Evros in 2010, according to the United Nations refugee agency. Neither the Greek authorities nor Europe's border agency Frontex could provide more data.
In practice, rights groups say Greece's barrier - and others including one built by Spain in Morocco - effectively turn everyone away, denying vulnerable people a chance to make their case for protection.
%shareLinks-quote="By building fences, by deploying barbed wire, it is not a solution. " type="quote" author="Dimitris Avramopoulos" authordesc="Europe's migration chief" isquoteoftheday="false"%
This is partly because some new barriers have passport controls like those at an airport. People need travel documents to exit one country and reach the checkpoint of the EU country where they want to seek asylum. Many refugees don't have any papers, so they are automatically blocked.
With barriers come security guards, cameras and surveillance equipment, which all make it harder for people to make their asylum cases. Rights groups have documented many reports of border officials beating, abusing, or robbing migrants and refugees before dumping them back where they came from. This approach, known as push-back, has become an intrinsic feature of Europe's external borders, according to Amnesty International.
As a solution, some migrants and refugees buy fake papers. Others stow away in vehicles. Or they turn to people-smugglers.
Greece's fence had a knock-on effect that continues to ripple through Europe as more countries wall themselves off. More migrants moving through Turkey began to enter Europe across the Bulgarian border, or by sailing to Greece in inflatable dinghies. In the eastern Mediterranean, the International Organization for Migration has recorded more than 1,100 migrant deaths since the start of last year.
The EU refuses to fund fences, saying they don't work. As European Commissioner, Avramopoulos has tried instead to persuade fellow member states to show solidarity by offering homes to 160,000 refugees and migrants, mainly from Greece and Italy. As of March 15, just 937 asylum applicants had been relocated.
For Hungary's Prime Minister Viktor Orban, the idea of quotas is "bordering on insanity." Orban opposes a dilution of Europe's "Christian values" by multicultural immigrants and started building fences along Hungary's borders with Croatia and Serbia in late 2015.
Since the ethnic cleansing of the 1990s in the former Yugoslavia, Balkan states have been particularly sensitive to the risks of ethnic and religious conflict. Other countries followed Hungary with fences - even if most said they installed them to control the flow of people, rather than to preserve cultural purity.
When Austria started a barrier on its border with Slovenia in November 2015, it said it was necessary for crowd management. Then Austria capped the numbers of people it would admit, and how many it would allow through to Germany. By March, all these measures seemed to be having the desired effect: The number of migrants entering Germany from Austria had fallen more than sevenfold.
Even so, there were new signs the fences were simply reshaping, rather than closing, the migration routes. The numbers making the perilous crossing from Africa to Italy had increased. Austria said it would add soldiers to defend its border with Italy.
The fence Avramopoulos visited last month underlines the risks of such barriers. Built by Macedonia as part of a pact with states further north, it has sealed around 50,000 people into Greece.
More than 10,000 - a third of them children - are camped in flimsy tents near the fence. Many families have refused to leave the border, waiting instead for it to open, as respiratory infections spread and frustration mounts.
"All our values are in danger today," Avramopoulos said. "You can see it here."