MATMATA, Tunisia (Reuters) - In the arid valleys of southern Tunisia’s Djebel Dahar region, people have lived for centuries in underground houses whose earthen casing provides protection against searing summer heat and winter winds.

A general view of troglodyte houses in Matmata, Tunisia, February 6, 2018. REUTERS/Zohra Bensemra

But in recent decades, rural depopulation has meant fewer people live in the homes, which are composed of rooms hewn into the walls of an excavated circular courtyard. The few remaining families say they are attached to the homes and the land or see no way of moving.

“My father died, my mother died, the girls got married and I was left alone. They all went to lead their own lives,” said Latifa Ben Yahia, 38, who lives in a five-room troglodyte home in the village of Tijma.

“If I leave then the house will be gone.”

The homes are concentrated around Matmata, which lies in a cratered landscape dotted with palm trees and olive groves about 365 km (227 miles) south of Tunis.

They are highly unusual, though similar constructions are found across the border in Libya, to the southwest. In other parts of the Djebel Dahar, houses and storerooms were carved from rock and earth above ground.

Many families left the underground houses when new towns and villages were built in the 1960s and 1970s as part of a modernization drive by President Habib Bourguiba.

Slideshow ( 21 images )

Locals suspect Bourguiba wanted to dilute Berber communities as he strove to integrate them into the Arab nation after independence from France.

Disputes over inheritance and periods of drought or heavy rain, which can cause the houses to collapse, also contributed to the rural exodus.

Some built modern houses on adjoining land, using the traditional homes as stables or workshops.

Residents live largely off olive farming and tourism. Matmata became a popular destination after a troglodyte home converted into a hotel was used as a Star Wars set in the 1970s.

But tourism across Tunisia is still recovering from a sharp decline after the country’s 2011 Arab Spring uprising and major attacks targeting tourists in Tunis and Sousse in 2015.

“Before the revolution there was tourism. Since then there’s not been much, just some Tunisians who come on days off or holidays,” said Saliha Mohamedi, 36.

She says she is comfortable in the house, where she lives with her husband and four children and lets tourists visit in return for tips.

“If I got another house I would give it to (my children). This is where we have passed our lives,” she said.

Hedi Ali Kayel, 65, who runs a small shop in the village of Haddej, is one of the last people in the area who knows how to build and maintain the houses. The last new house he dug was in the 1970s.

Now he is fighting a lonely battle to save the ones that still exist. “Every time there’s rain I come and repair them,” he says. “I don’t let them go.”