ULAN BATOR, Mongolia — The land beneath Dolgor Dashnyam’s home is wet and gritty and smells of decay. Here, atop one of Ulan Bator’s largest landfills, Ms. Dashnyam lives under a roof made of soggy mattresses. She spends her days rummaging through piles of gin bottles and discarded animal bones, picking up pieces of scrap metal to sell in order to buy water and bread.

Ms. Dashnyam, 55, was once an ambitious college graduate who dreamed of owning a farm and getting rich. But a scarcity of affordable housing has pushed her and thousands of low-income residents to the fringes of Ulan Bator, the city of 1.4 million that is Mongolia’s capital, where they struggle for basic necessities like food and clean water.

“Nobody cares about us,” said Ms. Dashnyam, who makes about $3 a day and says she has been unable to obtain government-subsidized housing. She was laid off from a job in farming. “We don’t exist.”

Hundreds of thousands of people have flocked to Ulan Bator in recent years, drawn by the promise of high-paying jobs and a path to the middle class. Many are fleeing harsh conditions in the countryside brought on by climate change, with droughts and bitter winters devastating fields and livestock.