While both Al Qaeda and the Islamic State have branches operating in the area, the mission of the government forces here is not to combat jihadism.

Instead, these Nigerien soldiers are battling human smugglers, who transport migrants across the harsh landscape, where hundreds of miles of dunes separate solitary trees.

The migrants are hoping to reach neighboring Libya, and from there, try a treacherous, often deadly crossing of the Mediterranean to reach Europe.

The toll of the military engagement is high. Some smugglers are armed, militants are rife and the terrain is unforgiving: Each mission, lasting two weeks, requires 50 new truck tires to replace the ones shredded in the blistering, rocky sand.

Image

Civilians in Dirkou, Niger, loading a truck in preparation for crossing the harsh desert.CreditJoe Penney for The New York Times

But the operation has had an impact: Niger has drastically reduced the number of people moving north to Libya through its territory over the past two years.

The country is being paid handsomely for its efforts, by a Europe eager to reduce the migrant flow. The European Union announced at the end of last year it would provide Niger with one billion euros, or about $1.16 billion, in development aid through 2020, with hundreds of millions of that earmarked for anti-migration projects. Germany, France and Italy also provide aid on their own.

It is part of a much broader European Union strategy to keep migrants from its shores, including paying billions of euros to Turkey and more than $100 million to aid agencies in Sudan.

Italy has been accused of paying off militias in Libya to keep migrants at bay. And here in Niger, some military officials angrily contend that France financed a former rebel leader who remains a threat, prioritizing its desire to stop migration over Niger’s national security interests.

Since passing a law against human trafficking in 2015, Niger has directed its military to arrest and jail migrant smugglers, confiscate their vehicles and bring the migrants they traffic to the police or the International Organization for Migration, or I.O.M. The migrants are then given a choice whether to continue on their journey — and risk being detained again, or worse — or given a free ride back to their home country.

The law’s effect has been significant. At the peak in 2015, there were 5,000 to 7,000 migrants a week traveling through Niger to Libya. The criminalization of smuggling has reduced those numbers to about 1,000 people a week now, according to I.O.M. figures.

Image

The ruins of the old city of Dirkou.CreditJoe Penney for The New York Times

As a result, the overall flow of people has now gone into a notable reverse: For the last two years, more African migrants have been leaving Libya to return to their homelands than entering the country from Niger, according to the I.O.M.

One of Niger’s biggest bus companies, Rimbo, used to send four migrant-filled buses each day from the country’s capital in the south, Niamey, to the northern city of Agadez, a jumping off point for the trip to the Libyan border.

Now, the company has signed a two-year contract with the I.O.M. to carry migrants the other way, so they can be repatriated.

On a recent breezy evening in Niamey, a convoy of four Rimbo buses rolled through the dusty streets after an arduous 20-hour drive from Agadez, carrying 400 migrants. They were headed back home to countries across West Africa, including Guinea, Ivory Coast and Nigeria.

For leaders in Europe, this change in migrant flows is welcome news, and a testament to Niger’s dedication to shared goals.

Image

Migrants waiting out the heat to avoid damage to their cars at the Puit d’Espoir (Well of Hope) while traveling south across the Sahara.CreditJoe Penney for The New York Times

“Niger really became one of our best allies in the region,” said Raul Mateus Paula, the bloc’s ambassador to Niger.

But the country’s achievement has also come with considerable costs, including on those migrants still determined to make it to Libya, who take more risks than ever before. Drivers now take routes hundreds of miles away from water points and go through mined areas to avoid military patrols. When smugglers learn the military is in the area, they often abandon migrants in the desert to escape arrest.

This has led to dozens of deaths by dehydration over the past two years, prompting Niger’s civil protection agency and the I.O.M. to launch weekly rescue patrols.

The agency’s head, Adam Kamassi, said his team usually rescues between 20 to 50 people every time it goes out. On those trips, it nearly always finds three or four bodies.

The crackdown on human smuggling has also been accompanied by economic decline and security concerns for Niger.

The government’s closure of migrant routes has caused an increase in unemployment and an uptick in other criminal activity like drug smuggling and robbery, according to a Niger military intelligence document.

Image

Nigerien soldiers at rest station at the Well of Hope; they were escorting travelers and migrants south to Agadez, Niger.CreditJoe Penney for The New York Times

“I know of about 20 people who have become bandits for lack of work,” said Mahamadou Issouf, who has been driving migrants from Agadez to southern Libya since 2005, but who no longer has work.

Earlier this year, the army caught him driving 31 migrants near a spot in the desert called the Puit d’Espoir, or Well of Hope. While the army released him in this case, drivers who worked for him have been imprisoned and two of his trucks impounded.

The military intelligence document also noted that since the crackdown, towns along the migrant route are having a hard time paying for essential services like schools and health clinics, which had relied on money from migration and the industries feeding it.

For example, the health clinic in Dirkou, once a major migrant way station in northern Niger, now has fewer paying clients because the number of migrants seeking has dwindled. Store owners who relied on the steady flow of people traveling through have gone bankrupt.

Hassan Mohammed is another former migrant smuggler who lost his livelihood in the crackdown.

A native of Dirkou, Mr. Mohammed, 31, began driving migrants across the desert in 2002, earning enough in the process to buy two Toyota pickup trucks. The smuggling operation grew enough that he began employing his younger brothers to drive.

Today, Mr. Mohammed’s brothers are in prison, serving the six-month sentences convicted smuggler drivers face. His two pickup trucks are gathering dust, along with a few dozen other confiscated vehicles, on a Niger army base. With no income, Mr. Mohammed now relies on the generosity of friends to survive.

Image

Former migrant smugglers like Hassan Mohammed have lost their livelihoods in the crackdown.CreditJoe Penney for The New York Times

Image

Pick up trucks confiscated by the Nigerien military from migrant smugglers.CreditJoe Penney for The New York Times

Not all the migrants returning through Niger end up in their home countries, but remain in the country, competing for scarce jobs.

With Europe as a primary beneficiary of the smuggling crackdown, the European Union is eager to keep the effort in place, and some of the bloc’s aid finances a project to convert former smugglers into entrepreneurs. But the project is still in its pilot stage more than two years after the migrant crackdown began.

Ibrahim Yacouba, the former foreign minister of Niger, who resigned earlier this year, said, “There are lots of announcements of millions of euros in funding, but in the lived reality of those who are in the industry, there has been no change.”

The crackdown has also raised security concerns, as France has taken additional steps to stop migration along the Niger-Libya border that go beyond its asylum-processing center.

From its military base in the northern Nigerien outpost of Madama, France funded last year an ethnic Toubou militia in southern Libya, with the goal of using the group to help stop smugglers, according to Nigerien security officials.

Image

Employees of the International Organization for Migration and Niger’s civil protection agency leaving Dirkou, Niger, for a weekly patrol to rescue abandoned migrants.CreditJoe Penney for The New York Times

This rankled the Nigerien military because the militia is headed by an ex-Nigerien rebel, Barka Sidimi, who is considered a major security risk by the country’s officials. To military leaders, this was an example of a European anti-migrant policy taking precedent over Niger’s own security.

A French military spokesperson said, “We don’t have information about the collaboration you speak of.”

Despite the country’s progress in reducing the flow of migrants, Nigerien officials know the problem of human smugglers using the country as a conduit is not going away.

Even as Libya has experienced a net drop in migrants, new routes have opened up: More migrants are now entering Algeria and transiting to Morocco to attempt a Mediterranean crossing there, according to Giuseppe Loprete, who recently left his post after being the I.O.M.’s director in Niger for four years.

But despite the drawbacks that come with it, the smuggling crackdown will continue, at least for now, according to Mr. Bazoum, the interior minister. Migrant smuggling and trafficking, he said, “creates a context of a criminal economy, and we are against all forms of economic crime to preserve the stability and security of our country.”

For Mr. Mohammed, the former smuggler, the crackdown has left him idle and dejected, with no employment prospects.

“There’s no project for any of us here,” he said. “There’s nothing going on. I only sleep and wake up.”

Image

A salt mine in Bilma, Niger. The market for Bilma’s salt has decreased drastically because of insecurity in the region.CreditJoe Penney for The New York Times

A version of this article appears in print on , on Page A12 of the New York edition with the headline: E.U. Bankrolled Effort. Niger Pays the Price.. Order Reprints | Today’s Paper | Subscribe