An unprecedented surge of migrants into Spanish territory in North Africa marked the first test of the European Union’s new migration pact and has reignited the bloc’s debate over immigration.