ESSAOUIRA, Morocco — This Moroccan town offers a tempting formula to visitors: Buy a low-priced guesthouse in the old quarter, settle into an exotic paradise of souks and spice markets and then watch the tourists and money roll in like the hazy waves of the nearby Atlantic.

The real estate offices in Essaouira’s walled old quarter are filled with photographs and upbeat descriptions that tempt expatriates to invest in 18th-century riads, traditional Moroccan townhouses with floors of rooms facing an interior garden or courtyard. “Pleasant riad decorated by an artist. Seven spacious bedrooms and seven bathrooms. Panoramic views from a rooftop terrace. 330,000 euros,” or about $365,000.

“The dream is exactly the same as falling in love with a person,” said Jean-Gabriel Nucci, 63, the French co-owner of Riad Watier, a century-old primary-school-turned guesthouse in Essaouira’s old quarter. “But when you fall in love, you are blind to the risks. This city is easy to love. It’s very photogenic, but people don’t think about what it will be like to live on a daily basis in this city. It’s not just a postcard.”