Tens of thousands of migrants in recent days have crossed onto a tiny peninsula on Morocco’s coast governed by Spain, aggravating tensions over a border that has long troubled the relationship between the governments of Madrid and Rabat.

At least 34 people died trying to enter Ceuta, the head of the city’s local government said on Friday.

The peninsula, Ceuta, is one of only two cities on the African mainland that are officially part of Europe. In search of better economic prospects, thousands of migrants over the years have scaled a 20-foot-high border fence into Ceuta or entered the territory by sea in mass crossing episodes.

But so many migrants made the passage on Thursday that it prompted Spain to mobilize its military and ignited backlash from the country’s right-wing opposition. That faction has accused the government of Prime Minister Pedro Sánchez of being lax on border control.

Here’s what to know about the surge.

Why is Ceuta a crossing hot spot?

A six-mile-long peninsula on Morocco’s northern coast, Ceuta is a Spanish exclave fortified by a double fence and a Spanish police and paramilitary presence.

The city, which has been governed by Spain for centuries, along with Melilla, another autonomous Spanish city further east along the same coast, have the European Union’s only land borders with Africa.

That means migrants seeking better livelihoods, many of them from Morocco, frequently try to cross there into Europe.

In 2021, more than 10,000 people came over the border into Ceuta over two days. A year later, at least 23 migrants died in a stampede during an attempted mass crossing in Melilla. Many others have died at sea.

Some migrants swim around the fence. Others take short, illicit boat trips to Ceuta from Morocco. But mostly, they run and climb the fence, or use bolt-cutters to cut through it, and are often spotted by motion detectors and guards in observation towers in the process.

Spanish Army soldiers in Ceuta on Thursday.Credit…Antonio Sempere/Associated Press

(Here’s a fascinating story about Ceuta’s soccer team, which unpacks the territory’s relationship with Spain.)

What happened there this week?

An estimated 60,000 migrants have crossed into Ceuta since Thursday, said Juan Jesús Vivas, the head of its government. Spain’s interior ministry cited a lower estimate of 50,000 migrants.

The influx of migrants in recent days is far higher than it was in equivalent periods, even during the peak of the European migration crisis in 2015.

Spain’s government said in a statement that it was dispatching military platoons to enforce border security, increasing air and naval support and sending diving teams to patrol the waters. The European Union offered to send Spain support from Frontex, its border and Coast Guard agency, to reestablish order.

Mr. Sánchez, the Spanish prime minister, said from the border on Friday that his government was doing everything possible to repatriate the migrants who had entered the country “irregularly.” About 25,000 migrants have already returned home, Spain’s interior ministry said.

Still, hundreds if not thousands of young men were lingering on the beach in Ceuta on Friday. Some slept on the streets and in city parks.

The Moroccan government has yet to officially respond to the surge. Moroccan police and security forces were deployed near Fnideq, a town close to the border with Ceuta, where clashes erupted on Friday.

Thousands of migrants sought to cross from Morocco into the Spanish exclave of Ceuta on Thursday.Credit…Antonio Sempere/Associated PressWhy does this mass crossing matter?

The African mainland border has been a major source of domestic political tension for the left-wing government of Mr. Sánchez and a diplomatic pain point between Morocco and Spain.

Domestically, Mr. Sánchez has sought to project an image of Spain as the West’s new melting pot. He has embraced immigrants, especially Latin Americans, who speak Spanish.

But on Ceuta, Mr. Sánchez has drawn criticism from anti-immigrant and conservative political opponents, who accuse him of being lax on border control — as well as pro-immigrant advocates who criticize the government for harsh immigration enforcement tactics.

Right-wing critics seized on the moment Thursday, blaming Spain’s new plan to give undocumented migrants already in the country a path to legal status for attracting illegal arrivals.

“This is an invasion,” said Santiago Abascal, the leader of the far-right party Vox, who accused Mr. Sánchez’s government of purposefully inviting in the migrants, who he suggested, without evidence, were criminals, rapists and potential left-wing voters.

The government, however, has said that the high volume of illegal crossings was not part of its vision.

Spain is eager to keep up good relations with Morocco, in part to maintain its cooperation in deterring migrant arrivals. After the major crossing episode in 2021, Spanish government officials said that Morocco saw the migrants as a kind of currency, leveraging control over their movement across the border to extract financial and political prizes from Spain.

Hours after the migrants began pouring into Ceuta that year, Spain approved 30 million euros, about $37 million, in aid to Morocco for border policing.

It was unclear early Friday what had prompted the latest amassing of people in Ceuta. Several migrants told The New York Times on Friday that they were encouraged to cross into Ceuta by the Moroccan authorities. Mr. Sánchez said that the Moroccan authorities were willing to help repatriate the migrants.

Analysts said it was too soon to draw conclusions but that Morocco may have been upset about Spain’s recent effort to deepen ties with Algeria.

Jason Horowitz, Carlos Barragán, Ségolène Le Stradic and Monika Cvorak contributed reporting.