On land where Assyrian kings once reigned, an Iraqi farmer named Araf Khalaf surveyed the scrap of earth that has nurtured three generations of his family. It is little more than a mud hut and a scraggly vegetable patch, yet his land has become a battleground, one pitting efforts to preserve Iraq’s ancient treasures against the nation’s modern-day poor.

With violence ebbing, Iraqi and international archaeologists are again excavating and repairing the country’s historic sites. But they are running into a problem: thousands of Iraqis have taken up residence among the poorly guarded ruins of Mesopotamia, in illegally built homes and shops, greenhouses and garages. And they do not want to leave.

“My father grew up here,” Mr. Khalaf said. “This is our land.”

It is a familiar issue for other nations with troves of unrecovered antiquities, like Egypt. And to Iraqi authorities, the residents are nothing more than illegal squatters who need to be moved. Officials say they pose the latest threat to an archaeological patrimony that has been plundered by looters, pummeled by decades of war and disfigured by Saddam Hussein’s egotistical additions and renovations. They want to relocate the families and seal off the areas, much as Kurdish officials in northern Iraq did to clear away squatters from an ancient citadel overlooking the city of Erbil.

But so far, officials in Baghdad and other provinces have done almost nothing. Local politicians and archaeologists say they have no control over land designated as part of Iraq’s national heritage. Members of the national antiquities board say they do not have the resources to protect the sites. And Iraqi security officers say it is not their job to evict people.

“There is incredible neglect,” said Nagham Yaqub Yousif, who is in charge of the Nineveh provincial council’s tourism and archaeology committee. “We’ve asked so many times for them to stop the squatters and give funds to solve this problem, but we didn’t get a response.”

The police here in Mosul did ask at least one family to stop building a new home of cinder blocks and mortar to replace their old mud house, said the family’s matriarch, who called herself Um Ahmed, the mother of Ahmed. “They took our names and left,” she said. “One day, someone will come and ask us to leave.”

Qais Rashid, leader of the State Board of Antiquities and Heritage, says that Iraq has about 800 police officers assigned to protect more than 12,000 archaeological sites, making it impossible to monitor anything but the barest fraction. The neglect has allowed looters to siphon off artifacts and Iraqis to move unhindered onto the sites.

“It hurts us,” Mr. Rashid said at a recent panel discussion about threatened historic sites. “It is a pain to see how few people are guarding these places.”

Some of the squatters (there are no accurate headcounts) are opportunists who have built pastel-hued concrete homes and businesses — even a factory — with an eye toward selling the properties quickly. Others move to the sites, hoping to be paid to leave.

But many more are among the estimated 1.3 million Iraqis who have been displaced by war. Living out of tents and shacks of scrap metal and plywood, the armies of the displaced are among the lingering echoes of a fierce sectarian war, and now pose an intractable humanitarian problem for Iraq’s government.

Ali al-Jabouri, dean of archaeology at Mosul University, said some of the squatters claimed land rights stretching back to the Ottoman Empire, whose dissolution after World War I led to the creation of modern Iraq. Ottoman administrators would grant decrees called fermans allowing for, among other things, the right to travel through a country or farm and live on a piece of soil.

“When they took the land they didn’t know there was archaeological heritage under them,” said Mr. Jabouri. “They think they have the right to use their own land. But they are breaking the laws.”

The families just inside the walls of the ancient city say they are simply trying to live.

“We live here peacefully,” said Haji Khalaf Bilal al-Badrani, father of Mr. Khalaf, the farmer. “One day we eat tomatoes; one day we eat a piece of bread. As long as we don’t steal, we are fine.”

Many of the mud-walled homes sit in the shadow of the reconstructed Mashki Gate, a soaring entryway to Nineveh, described in the biblical Book of Jonah as “an exceedingly great city.” It was attacked and mostly destroyed in 612 B.C. and unearthed in the 19th century by British archaeologists who hauled away inscribed tablets, sculptures and stunning reliefs. Today, the Global Heritage Fund says looting and creeping development put the sprawling site in danger of being “buried forever.”

But Araf Khalaf said his family was part of the stream of history, not something polluting it. He said he grew up within sight of the walls demarcating ancient Nineveh. He raises cows and works part time as a watchman. His wife makes khubz — a crusty flatbread — in an outdoor oven. His daughters chase chickens through the grass, and in the distance, shepherds drive their flocks past a grassy mound that has disgorged ruined palaces, cuneiform tablets and other shards of an empire that arced across the Middle East.

His parents hosted Western archaeological students when he was a boy. And while officials have long accused squatters of looting their surroundings, Mr. Khalaf said he had protected the gate and the main dig site from the widespread pilfering that accompanied the American invasion. He never, he said, touched a brick.

He will leave if the government tells him to go. But even if his house is demolished and his crops are abandoned, he said, he will still be drawn to the place.

“If a dove flies away, it always returns home,” he said. “It’s the same for us.”