Spain is trying to turn back a growing wave of African migrants who seek to enter the country through its southern coast or its small enclaves in North Africa.

About 800 migrants rushed the border fence in the enclave of Ceuta on Friday. At least 30 managed to climb over the seven-meter-high fence according to Spanish police, who turned back hundreds more with help from Moroccan riot police.

Ceuta and another city along the Moroccan coast, Melilla, have been Spanish possessions since the 1500s.

Earlier in the week, the Spanish coast guard rescued about 60 migrants trying to cross the narrow sea strait that separates Spain from Africa in flimsy rubber boats.

The number of immigrants reaching Spain, most of them from sub-Saharan African countries, tripled from 9,000 last year to 27,000 in 2017, according to Spanish Interior Minister Juan Zoido, who has said that controlling illegal immigration is one of his government’s “top priorities.”

The influx remains well below that of Italy’s, which has received over 100,000 immigrants this year.

But Spain is preparing for more scenes like the one in Ceuta.The United Nations refugee agency says African immigration routes are increasingly shifting away from Libya, the African country closest to Italy, and into Algeria and Morocco, which are are closest to Spain. Incidents of abuse and enslavement inflicted by Libya-based human traffickers are causing the change.

Spain enhanced border protection recently by placing concertina wire atop the fences that surround the 15 kilometer perimeters of Ceuta and Melilla. Heat-sensitive thermal cameras monitor movement along the fences at night, when most border crossings take place.

Often, Spanish police also direct heavily-armed Moroccan teams to points where they detect groups of aliens massing near the fence.

Despite these defenses, large groups have managed to jump, cut or crash through barriers on at least three occasions this year.

“This is starting to look like the U.S. border with Mexico,” a senior Spanish security official told VOA.

Once on Spanish soil, African migrants apply for European Union passes that give them the right to travel anywhere in Europe. The passes usually take just three or four months to process. Immigrants from Guinea and Cameroon, interviewed by VOA at a temporary detention center in Ceuta, say they are headed for France.

Spanish Interior Minister Zoido recently criticized NGOs that offer legal aid to new arrivals for ignoring security concerns.

Most of the migrants come from from Islamic-majority countries, and Spain fears terrorist attacks by Islamic State and other militant groups. Authorities in Ceuta this year rounded up two cells linked to IS that were allegedly preparing attacks.

A Spanish Civil Guard general, Franciso Espiosa, was recently appointed to head an EU military task force that will operate in Africa’s Sahel region, in hopes of stemming the immigrant tide. Espiosa is in charge of activities that range from training local gendarmes to direct missions against human trafficking rings and suspected terror cells.