The European Union’s top court has ruled three countries broke the law by rejecting refugees during the migration crisis five years ago. Poland, Hungary and the Czech Republic ignored a bloc-wide effort to share refugees and “failed to fulfil their obligations under European Union law”. The ruling opens the way for possible fines. The European Commission, the EU’s executive branch, brought the case after the countries refused to apply a relocation mechanism decided by the bloc’s leaders to distribute 120,000 asylum-seekers. Responding to Thursday's verdict, European Commission chief Ursula von der Leyen said "this ruling is important. It is referring to the past but it will give us guidance to the future." The three countries had citied national security reasons in refusing to take people in. “Those member states can rely neither on their responsibilities concerning the maintenance of law and order and the safeguarding of internal security, nor on the alleged malfunctioning of the relocation mechanism to avoid implementing that mechanism," the European Court of Justice said. Countries such as Greece and Italy that were hosting large numbers of migrants saw a backlash after 2015 as they struggled to deal with the mass arrivals. The migration emergency eased the following year when the European Union struck a deal with Turkey to block the passage of most migrants towards the EU in exchange for billions of euros. Most of the one-million-plus migrants that headed for Europe in 2015 were Syrians fleeing civil war. “We lost but that's not important - the important thing is we don't have to pay anything. The Commission pays the legal costs,” Czech Prime Minister Andrej Babis told state news agency CTK. He added that "the fundamental thing is that we will not take in any migrant and that the quotas have since disappeared, and that is largely thanks to us".