MELILLA, Spain—For nearly a decade, Spain has counted on tall border fences to discourage migrants from crossing illegally from Morocco into two small Spanish enclaves on Africa’s Mediterranean coast.

But as growing numbers of Africans scale the barriers, Spanish officials have adopted a different strategy, one that appears to challenge European Union law: Paramilitary police, in stepped-up patrols, are deporting some fence jumpers as they drop into the enclaves.

EU law bars summary deportations and requires members to allow anyone who steps foot on their territory to apply for political asylum.

Spain is trying to finesse that requirement by declaring a “security perimeter” on the Spanish side of the border fences. It is no longer enough, it says, to clamber up the fences and tumble onto Spanish soil to be assured of an asylum hearing.

Instead, it claims, migrants detained in this zone can immediately be sent back to Morocco without a hearing. Authorities have proposed an amendment to Spain’s national-security law that would retroactively legalize this practice, which border police say has become routine.