The scale of the global humanitarian crisis that has been unfolding since the Arab spring precipitated revolt and instability across the Middle East in 2011 can feel overwhelming. In the past few weeks alone, terrible stories have emerged of the brutal treatment of Rohingya Muslims, forced to flee Myanmar to grim camps in neighbouring Bangladesh. A fortnight ago, CNN ran a devastating film shot undercover in Libya, showing young migrants from Nigeria being auctioned into slavery. The sight and sound of a market in human beings carries a weight that dwarfs other reporters’ graphic accounts of the scale of the trade. The impact of the CNN report drew unflattering attention to the EU-backed programme run by Libya to detain and repatriate migrants in order to prevent them attempting the Mediterranean crossing into Italy or Spain. This is an arrangement of convenience for Europe. It has led to migrants being held in wretched and degrading conditions that in an unusual rebuke of the countries that pay a significant part of the costs, were condemned by the UN as “inhuman”. This week the EU met with members of the African Union in Addis Ababa. The EU has now signed up to a programme to repatriate migrants rather than leaving the huge task to a country that is still in turmoil after the fall of Gaddafi, which was backed by the UK, France and the US.

The great majority of the world’s displaced people flee to the nearest safe place, often another poor or middle-income country: in the past year a million refugees have arrived in Uganda from South Sudan. By far the largest part of the responsibility for those displaced around the Middle East has been borne by neighbouring countries, in particular Turkey, Lebanon and Jordan. Europe has been reluctant and defensive in responding to a crisis for which it is at least partly to blame. There has been a complete failure to agree a fair process for resettlement of refugees across the 28 member states. Greece and Italy have been left, for years now, to manage an unprecedented influx of desperate men, women and children. In an unparalleled international political vacuum, there has been little global leadership.

Last year, the New York declaration on refugees and migrants tried to lay the framework for a positive approach. It starts with recognising realities: the forces that motivate young people to risk death in the hope of a better life need to be met not by the kind of resistance that ends up with thousands being penned up in a filthy Libyan detention centre, but by opening up legal channels of migration.

Migrants want to work, and they want to be able to send cash home. Remittances are worth many billions of dollars to the economies of the global south; they cannot replace development aid, but they far outstrip its value. This time next year a UN refugee summit in Morocco aims to have a programme for legal migration in place.

A humane policy for migrants would make it easier to distinguish and meet our obligations to refugees, those who flee in fear. The responsibility for displaced people has fallen on poorer countries in a grossly disproportionate way. At the very least, there should be a programme of education so that every child in every camp has a school place. Internally displaced people need to be helped to find work (not always easy) and supported with direct cash payments that will go back into the local economy. But all of this depends on changing attitudes, above all moving away from the language of threat. Many people in the rich world want to – and do – support refugees, often in a more personal way than giving money: Canada’s scheme, for example, of finding sponsors for 15,000 Syrian refugees was hugely oversubscribed. Fear often speaks with a powerful voice. But so can that other great human emotion, solidarity. The former foreign secretary David Miliband has called this crisis a test of humanity. It is one that we must not fail.