MEKNES, Morocco – “So you travel ... only?” asked the woman sitting next to me in halting but intuitive English as we sat in the packed compartment on a train speeding through Moroccan farmland. We were the sole unveiled, accompanied women in the car.

Traveling alone in this North African, Muslim country where public spaces are almost exclusively male, I got that question everywhere, from the frequent flyer lounge in the capital’s airport to the kitchen of a riad – a traditional home with a courtyard – deep in Fez’s medina, the ancient walled section of the city.

With sexual harassment and assault making news from Egypt to India to Brazil, I was keenly aware that as a blonde Western tourist, I could not pass unobserved. And observe, glare and leer many Moroccan men do. A journalist told me his sisters living in Casablanca were desperately tired of being “eye-raped.”

In January and June, I spent more than three weeks exploring Morocco, from its imperial cities to the desert oases, mostly alone, but at times accompanying a group of students from a U.S. university where I teach. They were all women but one.

The group, despite modest dress, literally stopped traffic. Alone, I learned to firmly say “la, shukran” – no, thank you – to any invitation or approach, and got to enjoy the country through a woman’s eyes. That meant some pavement-staring to avoid confrontations, but also unexpected glimpses into this mesmerizing land where a wealth of cultures with ancient roots abuts illiteracy and subsistence.

As my seatmate on the train and I shared universal girl talk about kohl eyeliner and marrying the loves of our lives, this hairdresser from Casablanca reminded me of the spunky women portrayed in the stunning Roman mosaics in Volubilis, a few miles north of our train tracks in north-central Morocco.

The nearly 2,000-year-old city ruins, with a triumphal arch and rows of basilica columns topped by storks, loom in magnificent isolation amid a rolling landscape of olive trees. As donkeys laden with harvested greens plod along its dusty roads, little seems to have changed.

But the colorful floor mosaics of skimpily dressed, frolicking gods and goddesses visualize drastically different mores. A few hours’ drive north through the Rif mountains, on a pebbly Mediterranean beach nearly in sight of Spain, I alone wore a bikini among women sporting veils and ankle-length tunics.

The modesty equation was suddenly reversed when I prudishly put on that same bikini for a separate visit to a hammam – baths – in Fez, the eighth-century capital of the first Arab, Islamic dynasty to rule Morocco from the same lush farmland as Volubilis.

A muscular, sweaty masseuse nonchalantly pulled it off, leaving me covered only in olive-based black soap and precariously balanced on a marble slab. As she scrubbed roll after giant roll of dead skin cells off me, I overheard a dozen other preening naked women sharing a friendly laugh at the “dirty American,” as one put it.

In Fez, the medina is a gigantic beehive of windowless, earth-toned homes and shops crammed in a bowl-shaped river basin. In Marrakech, built by the dynasties that ruled Morocco from the 11th through the 13th century, the medina’s rose-colored walls stand out in the desert against the snowy Atlas mountains.

In either medina, if you like endless haggling, follow the flow of local women through the maze and load up on everything from sweets to expensive leather and metal handicrafts.

If you hate shopping, as I do, absorb the colors and smells while making a beeline for the many madrasas, or Islamic schools. In the centuries-old Ben Youssef school in Marrakech, tiny dorm rooms face a sunny courtyard where every inch is a kaleidoscope of intricate wood carvings, stucco inscriptions, and geometric mosaics.

Most tourists in Marrakech concentrate on the souks around Djemaa el-Fna, the medina’s central square bustling with food stalls come dusk. That leaves blissfully deserted grand 16th-century monuments, like the ruined El Badi palace of pink sandstone and the Saadian tombs, a burial complex covered in blindingly colorful tiles.

The same goes for another former imperial capital, Meknes, less than 50 miles from Fez. I skipped the medina and wandered through the eerily empty, gigantic late 17th-century royal granaries and stables.

To head from Marrakech along the fabled former trade route to Timbuktu, I relied on a guide and driver for a three-day personalized tour of sheer desert magic.

As the temperature rose to 118 F, we wove through ancient fortified adobe villages baked in the salmon-colored hills, hidden valleys bursting with date palms, and lulling Saharan dunes. My qualms about sleeping alone in a tent evaporated by the time I reached it on the back of my camel, led by a Bedouin guide who walked through the moonlit desert with unerring mental GPS, and a functioning iPhone.

Most trips to Morocco begin or end in the modern political and business capitals, Rabat and Casablanca, where the suffused ocean light and white art-deco districts recall, improbably, the architecture of South Beach.

In Casa, I admit my highlight was a fake: Rick’s Cafe, which opened in 2004 to recreate the locale of the 1942 classic movie “Casablanca.” Channeling Ingrid Bergman, I requested “As Time Goes By,” but was told it’s only played at night. Here’s looking at superb shrimp pasta and olive bread, instead.

In Rabat, the historic sites line the Bou Regreg river. Just outside the city center is Chellah, a Roman ruin, once a necropolis and later an Islamic religious center, and now the rare green space without ogling hassles.

Walking toward the ocean, you pass the 12th-century unfinished Hassan tower next to the gleaming mausoleum of the current king’s grandfather before reaching the white-and-blue Kasbah des Oudayas. High on a cliff over the Atlantic, encircled by medieval walls and palm trees, it’s the postcard shot of Rabat.

In its comparatively compact, linear medina, I spent one evening watching generations of women literally let down their hair – veils removed – to cook couscous and bake almond pastries as a TV soap opera blared in the house’s central courtyard.

In a busy cafe near the French colonial Ville Nouvelle neighborhood, I shared chocolate pastries, smoothies and Cokes with female Moroccan students working on a documentary about sexual harassment.