Before the tourists came to marvel at the valley cradled in Morocco’s Atlas Mountains, with its arid red slopes splashed with lush green and its deep-blue lake, the only living to be made was in olive farming, and not much of a living at that.

Then came the modest little hiking lodge and the luxury resort, and the quasi-palace owned by Richard Branson and the inns set up by the people of the Ouirgane Valley, many of whom are members of the Amazigh ethnic group, more commonly known as Berbers.

As more and more tourists discovered over the last few decades that the area was only an hour’s drive from the city of Marrakesh, the residents of villages like Ouirgane got jobs as guides for mule riding and hiking, drivers, waiters, hoteliers, restaurateurs and more.

Many were able to move back home from Moroccan cities like Marrakesh and Essaouira, where they had taken jobs to support families in their villages.

It was a success story that Morocco replicated across the country. By 2019, before the coronavirus pandemic paralyzed the sector, tourism accounted for about 7 percent of the kingdom’s gross domestic product and an estimated half-million jobs, a vital source of growth in a largely agricultural country struggling with drought.

The industry was just starting to recover from the pandemic when the region around Ouirgane was hit by a 6.8 magnitude earthquake, killing more than 2,900 people. Entire villages and towns were destroyed, imperiling the businesses that supported them.

“Tourists come from all over the world and take pictures,” said Khalid Ait Abdelkarim, 36, the manager of Domaine Malika, a stylish boutique hotel perched in the lush hills of Ouirgane.

He wore a welcoming smile, despite having spent the last four nights sleeping outside with his wife and 2-year-old daughter after his mud-brick home collapsed.

Since the earthquake, Mr. Ait Abdelkarim said, the hotel had received 50 cancellations, leaving a couple of French journalists covering the disaster as the only guests. If the high season, which runs through the fall, was wiped out, Mr. Ait Abdelkarim and the hotel’s dozen other workers would face a tough winter at a time when they had all lost their homes to the earthquake.

It was the same situation or worse at other hotels in the area. A few had been damaged badly enough to close, including Mr. Branson’s luxury hotel, Kasbah Tamadot, and Chez Momo II, a guesthouse built by Mohamed Idel Mouden, an Ouirgane native.

Khadija Id Mbarek, who was sitting in a tent next to the remnants of her collapsed home in Ouirgane on Tuesday, said she had saved the money she had made from weaving rugs for years to open a cafe that mostly catered to tourists. She learned to speak Arabic on top of her native Amazigh to communicate with visitors. Serving food and Moroccan mint tea, she earned enough to build a bed-and-breakfast.

Everything is gone.

“Actors would come here, foreigners, drivers, tour guides. I had so many friends,” she said. “I worked so hard. Sweated so much. I did everything for my daughters.” She said two of her children — both daughters — had died in the earthquake.

Despite being regarded as a bright spot in North Africa thanks to industries like tourism and electric vehicle manufacturing, Morocco’s economy had been under pressure well before the quake. It slowed sharply between 2021 and 2022 because of drought and higher commodity prices, which affected imports, according to World Bank data.

“That is an absolutely devastating event for people in rural areas,” said Max Gallien, a political scientist at the Institute of Development Studies in Britain who specializes in the Middle East and North Africa.

Though the country’s gleaming airports, high-speed trains and sophisticated restaurants impress visitors, the earthquake and the government’s slow response in remote villages has exposed the deep inequality of rural areas.

In many Amazigh villages deep in the Atlas Mountains, roads were bad, medical care was far away and schooling limited even before the quake.

Mr. Ait Abdelkarim said that a law requiring people in villages like Asni, where he is from, to build in the traditional Amazigh style, in order to maintain the area’s picturesque rustic look for tourists’ benefit, may have contributed to the devastation. Lifting the requirement would have allowed villagers to build sturdier homes, he said.

“We are not against the tourists taking pictures and coming to Morocco. We even welcome them to our houses. That’s what Moroccan people do,” he said. “But we also deserve good lives.”

However, Amine Kabbaj, a Marrakesh-based architect, said that traditional architecture could meet earthquake-resistant building standards if constructed with expert help.

It is the tourists who keep these villages and other parts of the country afloat. To save revenue and jobs, tour operators and businesses outside the hardest-hit areas were attempting business as usual this week, and often succeeding.

Tourists got lost as they always had in Marrakesh’s ancient medina; they chatted at the breakfast buffet of the Kenzi Rose Garden hotel about the thin-crust pizza they had sampled last night, and about what to see today. A top travel provider broadcast an update emphasizing that tourist destinations beyond the earthquake zone, including the ancient city of Fez, the Sahara and the blue-walled city of Chefchaouen, were just fine.

In that spirit, a uniformed staff member at Olinto, a luxurious new retreat set in a gently whispering olive grove near Ouirgane, was manning the front door with seemingly perfect composure on Tuesday afternoon, even though he had spent the last few nights in a tent.

“The best way to help Morocco is to visit it,” said José Abete, an American who opened Olinto with his French-Italian partner last year. They were preparing to welcome their first guests since the quake, who had not revised plans to stay for 16 days.

Olinto and a neighboring hotel, Domaine Malika, suffered a few cracks and broken objects.

At Chez Momo II, so named because the owner had to rebuild the original Chez Momo to move it out of the way of a dam, the restaurant and two upstairs rooms collapsed in the quake.

It looked as if a landslide had stopped just short of the edge of the pool. In the lobby, the paintings, traditional Amazigh doors and vintage objects that the owner, Mohamed Idel Mouden, had lovingly collected over the years hung askew.

Mr. Mouden, 45, was busy on Tuesday serving tea to people passing by and dropping off donated supplies in Ouirgane — his hometown. He was optimistic that the government would help fund rebuilding, given the local importance of tourism.

“Since everyone is damaged, why should I feel bad about it? I like building anyway,” he said. “There was Momo I, there was Momo II, and now there’ll be a Momo III.”

Yassine Oulhiq and Matthew Mpoke Biggcontributed reporting.