DAKAR, Senegal — The 613 men had traveled from their native Niger to neighboring Libya, where many of them planned to reach Europe over the Mediterranean Sea, a journey thousands of people from sub-Saharan Africa endeavor to make every year.

But late last month, the men were deported by Libyan authorities in one of the country’s largest expulsions in years. The mass deportation is part of a common pattern: North African governments, funded by the European Union to tackle migration, using brutal tactics to block sub-Saharan Africa migrants from heading to Europe.

The 613 men reached Niger’s closest town to the Libyan border on Jan. 3, disheveled and hungry, some barefoot and sick after months of detention and days of travel across the Sahara. Two of the men died shortly after arriving in Niger.

“I lived through hell,” said Salmana Issoufou, one of the men. Issoufou, 18, said he had been beaten by Libyan prison guards with wires and weapons throughout his eight-month detention.

As anti-migrant sentiment rises across Europe, from France to Germany to Hungary, the citizens of sub-Saharan Africa trying to reach the continent are being pushed back by North African governments in proportions unseen in years. The EU has signed bilateral agreements with Tunisia, Morocco, Libya and Mauritania that include financial support to curb migrant flows.

The strategy appears to be working: Illegal border crossings dropped sharply in 2024, according to recent data from the European Union’s border agency, Frontex.

But rights groups say the methods being used to keep sub-Saharan migrants from traveling to Europe include well-documented human rights violations, such as so-called desert dumps. Migrants have been abandoned in the Sahara without food or water, or kept in North African prisons where they face torture, sexual violence and starvation.

Since Tunisia struck a deal with the European Union in 2023, it has dumped more than 12,000 people, including children and pregnant women, into deserted areas of Libya, according to the United Nations. Last year, the EU signed a similar deal with Mauritania.

In Libya, the European Union has financed the country’s coast guard, which has been accused of firing live ammunition during interceptions at sea and of handing migrants over to violent militias.

An investigation by a consortium of news outlets last year showed that vehicles and intelligence provided by EU countries have been used by North African security forces to arrest migrants or transport them to desert areas.

The 613 men who were sent back to Niger this month were detained in Libya since at least last fall, according to regional officials in Niger, who escorted them from the border to Dirkou, a Nigerien town.

Two men died in Dirkou, according to Abba Tchéké, a social worker who assisted the men there and who works for Alarm Phone Sahara, a nonprofit that rescues stranded migrants in the desert.

The men reached Agadez, the largest city in Niger’s north and a major transit hub for migrants, last week. They were exhausted and dehydrated, and some had skin lesions and broken limbs. Half a dozen men who were deported all said in interviews with The New York Times that they had been mistreated by the Libyan authorities.

Adamou Harouna, 36, said prison guards had burned plastic on him while he was being held.

The mass deportation from Libya echoes similar movements from Algeria, which shares a 580-mile-long border with Niger and last year deported more than 31,000 people. The Algerian authorities drop migrants at the border with Niger, forcing them to walk for hours in the desert before reaching the closest town.