AGADEZ, Niger — The world dismisses them as economic migrants. The law treats them as criminals who show up at a nation’s borders uninvited. Prayers alone protect them on the journey across the merciless Sahara.

But peel back the layers of their stories and you find a complex bundle of trouble and want that prompts the men and boys of West Africa to leave home, endure beatings and bribes, board a smuggler’s pickup truck and try to make a living far, far away.

They do it because the rains have become so fickle, the days measurably hotter, the droughts more frequent and more fierce, making it impossible to grow enough food on their land. Some go to the cities first, only to find jobs are scarce. Some come from countries ruled by dictators, like Gambia, whose longtime ruler recently refused to accept the results of an election he lost. Others come from countries crawling with jihadists, like Mali.

In Agadez, a fabled gateway town of sand and hustle through which hundreds of thousands exit the Sahel on their way abroad, I met dozens of them. One was Bori Bokoum, 21, from a village in the Mopti region of Mali. Fighters for Al Qaeda clash with government forces in the area, one of many reasons making a living had become much harder than in his father’s time.

One bad harvest followed another, he said. Not enough rice and millet could be eked out of the soil. So, as a teenager, he ventured out to sell watches in the nearest market town for a while, then worked on a farm in neighboring Ivory Coast, saving up for this journey. Libya was his destination, then maybe across the Mediterranean Sea, to Italy.

“To try my luck,” was how Mr. Bokoum put it. “I know it’s difficult. But everyone goes. I also have to try.”

This journey has become a rite of passage for West Africans of his generation. The slow burn of climate change makes subsistence farming, already risky business in a hot, arid region, even more of a gamble. Pressures on land and water fuel clashes, big and small. Insurgencies simmer across the region, prompting United States counterterrorism forces to keep watch from a base on the outskirts of Agadez.

This year, more than 311,000 people have passed through Agadez on their way to either Algeria or Libya, and some onward to Europe, according to the International Organization for Migration. The largest numbers are from Niger and its West African neighbors, including Mr. Bokoum’s home, Mali.

Atlantic Ocean Mediterranean Sea ALGERIA Canary Islands NORTH AFRICA Sahara LIBYA Tamanrasset WEST AFRICA NIGER Tambacounda region Mopti region Sahel Agadez SENEGAL CHAD Zinder GAMBIA Chana MALI GUINEA NIGERIA IVORY COAST GHANA CAMEROON Gulf of Guinea Atlantic Ocean Mediterranean Sea ALGERIA NORTH AFRICA Sahara LIBYA Tambacounda region Mopti region NIGER Agadez Sahel SENEGAL Zinder MALI WEST AFRICA NIGERIA Gulf of Guinea

Scholars of migration count people like Mr. Bokoum among the millions who could be displaced around the world in coming decades as rising seas, widening deserts and erratic weather threaten traditional livelihoods. For the men who pour through Agadez, these hardships are tangled up with intense economic, political and demographic pressures.

“Climate change on its own doesn’t force people to move but it amplifies pre-existing vulnerabilities,” said Jane McAdam, an Australian law professor who studies the trend. They move when they can no longer imagine a future living off their land — or as she said, “when life becomes increasingly intolerable.”

But many of these people fall through the cracks of international law. The United Nations 1951 refugee convention applies only to those fleeing war and persecution, and even that treaty’s obligation to offer protection is increasingly flouted by many countries wary of foreigners.

Interested in keeping up with climate change? Sign up to receive our in-depth journalism about climate change around the world.

In such a political climate, policy makers point out, the chances of expanding the law to include those displaced by environmental degradation are slim to none. It explains why the more than 100 countries that have ratified the Paris climate agreement this year acknowledged that environmental changes would spur the movement of people, but kicked the can down the road on what to do about them.

A Barren Outlook

Many migrants pass through Agadez from the villages around Zinder, a city roughly situated between the mouth of the Sahara and Niger’s border with Nigeria. Until 1926, Zinder was Niger’s capital. Then it ran low on water.

Early one gray-yellow morning, I set off from Zinder for a village called Chana, the home of one of the migrants I had met, Habibou Idi. Rows upon rows of millet grew on both sides of the two-lane national highway, punctuated occasionally by a spindly acacia. About an hour outside the city, some boys were raking the soil, yanking out weeds.

An older man sitting to the side said that back when he was a boy, the millet stood so high that you could hardly see workers in the fields. Midway through the growing season, it now barely reaches their knees.

An hour farther out of the city, we veered off the paved road and across a barren, rutted field.

In Chana, there was a steady thud of women pounding beans with wooden pestles. The beans grew along the ground, in the shade of the millet. They were the only crop ready for harvest. And so the people of Chana ate beans, morning and night: beans pounded, boiled, flavored with salt.

As Mr. Idi, 33, led me through his fields, he recalled hearing stories of what Chana looked like before a great drought swept across the Sahel in the 1970s and 1980s. The village was encircled by trees, he was told.

Back then, like most villagers, his father had a cow and plenty of sheep. Their droppings fertilized the land. Today, Mr. Idi said, not a single cow is left in Chana. They were sold to buy food.

Mr. Idi complained that the rains are now hard to predict. Sometimes they come in May, and he rushes out to plant his millet and beans, only to find the clouds closing up and his crops withering. Even when a good rain comes, it just floods. Most of the trees are gone, they were cut for firewood.

Living off the land is no longer an option, so unlike his father or grandfather before him, Mr. Idi has spent the last several years working across the border in Nigeria — hauling goods, watering gardens, whatever he could find.

This summer, for the first time, he boarded a bus to Agadez, and then a truck across the dunes to Algeria. There, he mostly begged.

He lasted only a few months.

The Algerian authorities rounded up hundreds of Nigeriens and deposited them back in Agadez.

That is where I met him, in a line for the bus back to Chana. Sand filled the breast pocket of his tunic. He was bringing home a blanket, a collection of secondhand clothes and 50,000 CFAs (the local currency, pronounced SAY-fas), worth about $100.

That did not last long, either. Mr. Idi arrived home to find that his family had taken out a loan of nearly the same amount in his absence. They had sold four of their five goats, too. There were many mouths to feed: his wife, their four children, plus his late brother’s seven.

Hotter Hots and Unpredictable Rains

Sub-Saharan Africa is in the throes of a population boom, which means that people have to grow more food precisely at a time when climate change is making it all the more difficult. Fertility rates remain higher than in other parts of the world, and Niger has the highest in the entire world: Women bear more than seven children on average.

Once every three years, according to scientists from the Famine Early Warning Systems Network, or FEWS Net, Niger faces food insecurity, or a lack of adequate food to eat. Hunger here is among the worst in the world: About 45 percent of Niger’s children under 5 suffer from chronic malnutrition.

Meanwhile, in what is already one of the hottest places on Earth, it has gotten steadily hotter: by 0.7 degrees Celsius since 1975, Fews Net has found. Other places in the world are warming faster, for sure. But this is the Sahel, where daytime highs often soar well above 45 degrees Celsius (113 Fahrenheit) and growing food in sandy, inhospitable soil is already difficult.

Niger’s neighbors share many of those woes. In Mali, temperatures have gone up by 0.8 degrees Celsius since 1975. Summer rains have increased, but are not at the levels they were before the drought.

In Chad, temperatures have risen by 0.8 degrees Celsius in the same period, according to FEWS Net. The group, which is financed with United States assistance, has warned that cereal production could drop by 30 percent per capita by 2025.

Chad is where FEWS Net’s chief representative for the Sahel, a meteorologist named Alkhalil Adoum, was born in 1957. As a boy, he loved running through the blinding rains of summer, when you couldn’t even see what was ahead of you. He knew a good rain would fill the savanna with wild fruit, and the first green shoots of sorghum would taste as sweet as sugar cane. His family’s cows, once they ate new grass, would give more milk.

“You love the first rains,” Mr. Adoum said. “You know, as a kid, there’s better times ahead.”

Those rains don’t come anymore, he said.

There are conflicting scientific models about the effects of climate change on precipitation: some say much of sub-Saharan Africa will be wetter; others drier. The main points of agreement is that the rainy season will be more unpredictable and more intense. On top of that, the hottest parts of the continent will get hotter.

Extreme heat can have grievous consequences on food and disease, the World Food Program found in a survey of scientific studies. Malaria-carrying mosquitoes thrive in it. Pests are more likely to attack crops. Corn and wheat yields decline.

A study, published in December by the International Monitoring Displacement Center, found that in 2015 alone, sudden-onset disaster displaced 1.1 million people in Africa from one part of their country to another.

And then there is the competition over water. Already, it sets off clashes between farmers and herders, often hardened by ethnic divisions. A growing body of research suggests that local droughts, especially in poor, vulnerable countries, heighten the risk of civil conflict.

Risk analysts, including at the London-based firm Verisk Maplecroft, conclude that climate change amplifies the risks of civil unrest across the entire midsection of sub-Saharan Africa, from Mali in the west to Ethiopia in the East.

A grisly example lies in full display just a few hours by road from Mr. Idi’s village. In the southeastern corner of the country, where Niger meets Nigeria, Chad and Cameroon, more than 270,000 people huddle for safety from the Boko Haram insurgency. Altogether, across the Lake Chad Basin, 2.4 million people have fled their homes, according to the United Nations.

A City of Dreams

Agadez is a city of mud-brick compounds with high walls and blazing bright metal doors. For centuries, it was filled with traders and nomads. In recent decades, it was a tourist magnet, until ethnic rebellions and then jihadist violence drove people away.

Today, migration is the main industry. Drivers, smugglers, money changers, sex workers, police officers — everyone lives off the men on the move. It is a city of dreams, both budding and broken. It is where the journey across the desert begins for so many young West African men, and it is where the journey ends, when they fail.

The smugglers’ den where I found Mr. Bokoum, the 21-year-old from Mali, was a set of two adjoining courtyards, with two concrete-floored rooms. Upside-down jerrycans served as stools, plastic mats as sofas.

He had been in Agadez for three months, waiting for his mother to send him money. It can cost 350,000 CFAs — about $600 — to get from Agadez to the Libyan border, on the back of a pickup truck.

The smugglers had also started out as migrants, and most of them worked for a while in Libya. Now, they make money off other men’s journeys. None would hint at how much.

Mohamed Diallo, a Senegalese manager of the compound, blamed Western countries for spewing carbon into the atmosphere, and he was skeptical of their leaders’ promises to curb emissions.

“The big powers are polluting and creating problems for us,” he said. He was appalled that Africans trying to go to Europe were treated like criminals, when Europeans in Africa were treated like kings.

Mr. Diallo’s compound, like others in Agadez, has a weekly rhythm.

He instructs those seeking to make the journey to Libya to be inside by Sunday night. Monday morning, he treats them to a feast before the long haul. He roasts a sheep, plays some music, turns on the ceiling fans for a couple of hours.

Just after sundown, a white Toyota pickup pulls up. Monday night is when Nigerien soldiers change shifts, heading out of Agadez and into a desert outpost. The Toyotas follow, stopping briefly at the police checkpoint at the edge of the city before speeding into the dunes. Those who fall off the trucks are left behind.

The journey to the Libyan border, 250 miles in all, takes three days. No one knows how many die along the way.

Those who venture a journey across the Mediterranean take a deadly gamble, too. Among the more than 4,700 people who have died trying to cross the Central Mediterranean so far in 2016, the vast majority cannot be identified. Of those who can, Africans make up the largest share.

“The migrant road,” Mr. Diallo said, “is a road on fire.”

‘I Will Be a Burden to Them’

Those who make it to Libya do not necessarily make it inside Libya. It is a lawless country where some migrants get thrown behind bars — and some, according to human rights groups, are raped and tortured by militias demanding money. Some run out of money, or heart, to continue the journey to Europe.

On the way back, they usually knock on the gates of the International Organization for Migration’s transit center at the edge of Agadez.

There were about 400 boys and men there the week I visited. They lounged on thin rose-print mattresses. They played cards and scrolled through their phones, calling home if they had any credit left. A few attended a class on how to start a business; others rested in the medical ward.

The mix of shame and boredom hung so heavy you could practically smell it. One young man walked around with an open wound on his elbow; he vaguely said he was injured in a brawl in Libya.

When the heat of the day broke, they roused themselves and played soccer.

The migrants from the countryside all had similar stories. Their fathers had never left the land — they all felt they had to. The harvest was not enough; their families had no tractors, just lazy donkeys. Work in nearby towns brought in a fraction of what they figured they could make abroad.

The lure of abroad, Algeria or Libya or beyond, was strong. Facebook posts from friends and neighbors made it seem like a cakewalk.

Ibrahim Diarra said that fickle rains made it too hard to grow peanuts and corn on the family farm in the Tambacounda region of Senegal. He watched the young men of his village leave, each pulled by the stories of those who went before. Then he followed.

Mr. Diarra made his way through Qaeda-riddled northern Mali, then worked construction for six months in Mauritania, before pushing on to Tamanrasset, in Algeria. If he could just get to Morocco, he had heard, he could climb over a fence and be in Spain.

“They told me it’s very easy,” he said.

It wasn’t. He lasted two months in Algeria. Then, he went back to Agadez and asked the migration organization for a bus ticket home. So far this year, 100,000 people have made the same reverse journey.

On a Thursday — departure night for those whose emigration dreams are dashed — bittersweet chaos erupted in the courtyard as two large buses pulled up.

The manager of the transit center, Azaoua Mahamen, sat on the porch with his laptop open, scrolling through the names of those who had been cleared to go home. Migrants need identity papers, and government permission. If they are children, Mr. Mahamen has to make sure they have a family to go back to; a few don’t.

Dozens of young men crowded around him, their eyes like headlights in the dark.

They shouted their names. They waved their identity cards, wrapped in plastic. One group complained that only Guineans were getting out that night. The Ivory Coast contingent started cheering when one of their compatriots was called.

Mr. Diarra listened for his name, though he wasn’t looking forward to facing his parents empty-handed.

“I’m supposed to support my family,” he explained. “Now I have no clothes, nothing. I will be a burden to them.”

His father, especially, would be upset. “He’ll ask me how my friends got to Europe and I came back,” he said, shaking his head.

He said he would try the journey again. It would take him a few months to cobble together the money.