KUIK-E HASAN, Iran — In Kuik-e Hasan, a village of 800 people in the foothills of the Zagros Mountains, Moadel Yari, 35, stood biting his lip as he recited the names of the family members lost: “Amin, Hajar, Toba, Hajin, Abdellah, Boshra, Ozve, Somron.”

Iranians living near the border with Iraq are accustomed to earthquakes. They live in a region traversed by fault lines, and the destruction that comes when the ground shakes is not something new. And still, no one in this region was ready for the massive destruction and loss of life that occurred when the ground shook on Sunday night.

There are more than 530 dead, a massive loss in itself, but coming to terms with so much death — and the damage to so many structures, in a region of small villages and towns, all at the same time — was that much harder. This earthquake in northwestern Iran was deadlier than the one that devastated Mexico City in September. Tremors were felt as far away as Turkey, Israel, Lebanon and Qatar.

A lone Shiite cleric, wearing a backpack, sandals and his traditional turban, wandered through the flattened village of Kuik-e Hasan on Tuesday. The cleric, Asgar Zarei, had come from the holy city of Qom with other volunteers to help out, but found himself lost in the destruction. “I’m trying to talk to people about God, give them peace of mind — that is all I can do,” he said. “And pray. One can always pray.”

For the Iranian government, which is in a constant struggle to demonstrate that it can, and will, care for its citizens at times of crisis, the earthquake was a test of resources and capabilities. Citizens around Iran watched riveting news feeds on television and social media as survivors used backhoes and their hands to dig through debris in the search for survivors. But for the people in this region the struggle was more elemental — many are living in tents, huddled against the biting cold.

The government knew it was being watched. The country’s supreme leader, Ayatollah Ali Khamenei, called the quake “a divine test for officials and Iranians,” one that will determine “if they can carry out their duties.” President Hassan Rouhani visited the region and stopped in the worst-hit city, Sarpol-e Zahab, promising more help and low-interest loans to developers to rebuild collapsed apartment complexes.

The president called the disaster “painful for all Iranians.”

After receiving permission from the government to visit the disaster zone, I flew about 265 miles west from Tehran to the regional airport, in the city of Kermanshah. It was then a two-hour drive with an Iranian photographer, Arash Khamooshi, through rugged mountains to the city of Sarpol-e Zahab and the villages surrounding it.

After two checkpoints, one manned by police in riot gear — protection against bandits, the government said — we hit the main road. It was the only clear path through a town largely in ruins.

On the left, a truck blocked the entrance to a shop, cracked open like an eggshell. On the right was a series of apartment buildings; its balconies had fallen off. A mix of locals in banged-up cars, some with their windows broken from rubble, drove up and down. Soldiers from the Islamic Revolutionary Guard Corps in pickup trucks, and people bringing water, blankets and orange-flavored cakes from other cities, were also driving in.

“I came for a funeral,” said Kamran Moradi, from nearby Qasr-e Shirin, the last city before the border with Iraq. “I have never seen anything like this,” he said.

This is a region that is accustomed to tragedy. Its people have tasted the worst life can throw at them, many having survived eight years of war with neighboring Iraq. But they trusted. They thought they could rely on home always being there.

“I have seen everything,” said Mohammad Nazari, a veteran of the 1980-88 war.

He said he was slow to grasp the significance of the tremors on Sunday night in his hometown, the village of Zarrin Jub.

Just after 9 p.m., Mr. Nazari had been focused on his favorite television show. The first tremor felt oddly familiar, he said, but not all that menacing: Jackie, a black guard dog, had already been barking for an hour. He thought the tremor his dog had noticed was one of the small jolts people regularly experience in earthquake-prone Iran.

He went back inside to watch TV.

Not long after, the walls started shaking. He ran for the hallway, slamming into the walls. Sakine, his wife, ran behind him. “In those seconds you only think of yourself, of surviving,” Mr. Nazari said.

In the chaotic minutes following the quake, he was first overwhelmed with joy. “I am alive,” he recalled thinking over and over again. “Alive.”

Around the country, people began to rally, to gather goods to distribute to those in need. While the government said it did not need outside assistance, Iranians pulled together. In Tehran, volunteers started online campaigns to gather food and blankets for the victims of the earthquake. “We want to make sure these people get the help they need,” said Pouria Gorji, a factory office manager who supports Mr. Rouhani. “Our group is bringing 1,500 tents and 3,000 blankets. The government is overwhelmed.”

“Let’s be honest, we don’t have proper crisis management, but we always send a lot of people to help,” said Nader Karimi Joni, a journalist. “We should start preparing for better ways to deal with such terrible events.”

An official of the Red Cresent Society of the Islamic Republic of Iran in Sarpol-e Zahab said that 10,000 family-size tents had been brought in, but that distributing them had turned into a scrimmage. Iranians without tents or any other form of shelter accused low-level officials — and looters — of hoarding tents with plans to sell them later for a profit.

Mr. Nazari and several neighbors complained about their representative in Parliament, Farhad Tajari, who grew up in a village nearby. “Where is he?” Mr. Nazari asked. “Why is he not here? We voted for him and need him now.”

Some were already preparing for the night. They had parked their cars on a flat space of land. “We sleep in our cars, the remains of our houses are too dangerous and instable with all the aftershocks,” Mr. Nazari said.

In Kuik-e Hasan, where Mr. Yari recited the names of his loved ones, relatives arrived with from Tehran with a car full of blankets and food. His grandmother sat on a carpet in front of what had been her house, surrounded by cans and plastic bottles. “We still haven’t gotten a tent,” Mr. Yari said.

Others in his village were also frustrated, hoping the government would move faster.

“They can start with tents,” said Shahram Moradi, a 35-year-old shoe repairman.

Down the road a group of women sat on a carpet. They had neatly stacked up the bottles of water people had brought them, but feared the coming night. “Our 10-year-old boy Arman is still here under the rubble,” an older woman said, through her grief. “Tonight, we will sleep next to him.”

In Zarrin Jub, mourners sat in rows of yellow and green plastic chairs laid out in a field of wheat stalks. Several of them cried, not just for the man whose life they were commemorating, but from the loss of their homes, their neighbors, their village.

“He was a great and selfless guy,” said Zahra Eskandari, reflecting on her cousin, Cyrus Piri, who had been buried soon after his body was recovered from the rubble of his home. “He helped people whenever he could.”

Before the quake, Mr. Piri was the man called on to help bury the dead. He would show up at his neighbors’ funerals to sing for free, using his rich bass voice to extol the virtues of revered Shiite figures.

There was no one to sing at his funeral.