Holland’s multi-colored hamlets are nice, there’s no place quainter than England’s yellow-brick Cotswolds, and Greece has beautiful whitewashed islands. But few cities can compete with the magical charm of a hilly northern Moroccan outpost that was kept locked away from the rest of the world for centuries and is painted entirely in shades of blue.

Tucked into the Rif Mountains, the bright blue city of Chefchaouen seems like a mirage, situated as it is in the middle of an all green-and-tan landscape. The city was founded in 1471 as a base for Moroccans to fight off the invading Portuguese, who occupied the coastal areas. Its remote and mountainous location, four hours from the sprawling metropolis of Fez, kept the city insulated and enabled its inhabitants to successfully fend off foreign influence, unlike its bigger neighbor.

In the following centuries, Chefchaouen became known as a refuge for Jewish and Muslim minorities leaving Europe, and, for half a millennium, it managed to stay relatively isolated from the ever-changing rulers of Morocco. It wasn’t until the early 20th century that the walled city was finally captured by Spain and its gates opened to the outside world.