In the heat of battle emotions run high. But to allow such emotions to take over can engender mistakes as threatening to our way of life and liberties as any enemy. To a certain extent, this is what happened after the recent attacks in Paris on Charlie Hebdo and the Jewish community. The shock and revulsion generated by these attacks has seen many people yield to the temptation to mix together in the same confused amalgam the war against terrorism, our policy on the Middle East, border controls, irregular immigration, freedom of movement for workers, the role of Islam in our civic spaces, and the integration and assimilation of minorities of different cultures and religions into our societies.

Testifying to this confusion, in France we witnessed President Francois Hollande clamber aboard the Charles de Gaulle aircraft carrier to declare war on the Islamic State though doubts existed as to whether the attack was inspired by that group or by Al Qaeda. Similarly uncertain was whether or not a fiery warlike reaction was exactly what the attackers sought, or what the amplificatory effects of such an outburst could be, potentially encouraging future attacks. We then heard Nicolas Sarkozy call for an end to freedom of movement within the EU and the reintroduction of border controls in the Schengen area, the ex-President deliberately ignoring the fact that the Parisian attackers were French citizens born in France to whom border control could hardly represent an impediment.

We also saw Marine Le Pen and her xenophobic Front National demand the reinstitution of the death penalty or, in other contexts, the introduction of Penal Code imprisonment, both popular ideas with many voters but of zero effectiveness as an instrument in the struggle against jihadist terrorism. Added to the chorus were a series of complaints that combined hostility towards the Muslim community in France with a revived discussion of the inherently violent or peaceful nature of Islam, and its compatibility or incompatibility with democracy. In short, a large and unprofitable farrago.

Now that time has passed and calm is restored, we must separate issues and define problems and solutions. The best place to begin this task is the war against jihadist terrorism. That fight requires greater police, legal and intelligence coordination between Europeans and many more resources than are currently available. But the fight against terrorism is not confined to the police or courts: it requires a foreign and security policy worthy of the name. Our neighbourhood, an essential space for our security and prosperity, is fraying before us, making our borders – especially the Mediterranean – a funnel for the despair of millions of refugees fleeing from the conflicts and poverty that surrounds us. It is a relentless flow that requires far more than a well-intentioned but insufficient maritime rescue programme in the Mediterranean.

Progress in the field of European foreign policy, marked in the first decade of the last century, was paralysed and even to an extent reversed during the mandate of the former High Representative for Foreign and Security Policy, Catherine Ashton. Now it is time to regain political momentum in that area and finally provide the European Union with the military capacity to prevent conflicts before they start, stop them once they have begun and stabilise conflict zones to allow the reconstruction of peace and coexistence.

European foreign policy must operate as a trident in which diplomacy and defence are complimented by a policy of cooperation and development with the neighbourhood that together is endowed with sufficient resources. And we also need a competent asylum and refugee policy, coupled with the ability to respond decisively to emergencies and humanitarian disasters at our borders. This is not a case of crying wolf, but instead anticipating what is to come. According to the European border agency (Frontex), 270,000 people attempted to illegally enter the EU in 2014.

Now consider, given the experience of the three million Syrian refugees scattered across the continent, what could happen if Russia turns Ukraine, a country of over 43 million inhabitants, into an unworkably failed state and the Ukrainians flee to this side. If we do not stabilize our neighbourbood decisively, we will face a decade holed in behind ever growing walls with hundreds of thousands of illegal immigrants interned in detention camps and as many political refugees roaming Europe with no prospect of returning to their countries. Although it may sound contradictory, when we see European peacekeepers, judges, police, diplomats and aid workers deployed in our neighbourhood, from Ukraine to Tunisia, through Libya and the West Bank, it will be a sign that things are improving.

This huge task requires more Europe, not less, but above all a lot of courage on the part of political leaders. The European Union certainly is not popular today, and neither are the majority of its Member State governments. Perhaps that explains the reluctance of politicians to admit some very uncomfortable truths to the public about the ineffectiveness of the national sphere in resolving the major problems that we face. The narrative of European integration as guarantor of peace, security and prosperity has lost its backers. Rather, it is the sovereign nationalist narrative that is gaining alarmingly in popularity, hence the effort to end the free movement of people has become a common platform for xenophobes, including some governments like the Hungarian, who have no qualms with publically declaring that liberal democracy, that is, with rights, is not the only possible form of democracy.

If not simply for economic reasons, given the ageing problem that it faces, but also on the basis of its principles and values, Europe needs a complete overhaul of its immigration policy. Its borders should be porous and flexible yet secure, encouraging beneficial flows and deterring detrimental ones, while facilitating the return of immigrants to their countries of origin when feasible and contributing to their economic growth. By contrast, when borders hermetically close, people are trapped on both sides and migration flows are placed in the hands of criminal networks.

And finally, the EU must also maintain a firm stance on the issue of freedom of movement. To exist as a political and popular project, Europe needs to preserve that liberty; without it there would only be a free trade area with no political or civic dimension. When a Spaniard moves to Germany or a German to the United Kingdom, they are not emigrating: they are exercising a right and that right should be preserved. That there are abuses, fraud or welfare tourism cannot serve to curtail that right, but instead as an impetus to collectively improve the way in which the right is exercised. If we give in here, Europe will lose its very meaning. But that vital debate is a debate between us that has nothing to do with terrorism. If we cannot separate all these debates, we will not progress in any of them. And that is largely what is happening right now.