The authorities have struggled to contain the fallout, as frightened migrants flee the country.