Updated

Some of the world's most beautiful buildings take a little work to find.

Walled cities helped protect medieval people from foreign invaders but today they can hold a treasure trove of architectural masterpieces.

1. Dubrovnik, Croatia

90363f57-

(Jan Wlodarczyk/Alamy)

A 100-foot-tall wall surrounds this coastal city and offers epic views of the Adriatic Sea. The medieval structure, which encompasses towers, fortresses, and three separate gates, was rebuilt after an earthquake in 1667, which nearly destroyed the town. The reconstruction was devised by Italian architects, whose style would not clash with the Renaissance-style architecture that remained, including the Sponza Palace and St. Saviour Church.

2. Avila, Spain

5ca013c4-

(Stefano Politi Markovina/Alamy)

Construction on this mighty fortress—capped with precisely 88 turrets—began in 1090. Today, Avila is a thriving city containing two universities, a modern convention center by architect Francisco Mangado, and an impressive collection of medieval churches (including the 12th-century cathedral where Saint Teresa had her ecstatic visions).

3. Carcassonne, France

76e8a63b-

(Stefano Politi Markovina/Alamy)

Though beautiful, with its conical spires and double-ringed ramparts, this fairytale-like city is most remarkable for the fact that it even exists today. The strategic fortress was brutally sacked by the Visigoths, the Moors, and noble Languedoc clan the Trencavels, until it was finally seized by the kingdom of France in 1247. Left in near ruins in the 19th century, the city was restored from the ground up by French architect Eugène Viollet-le-Duc, resulting in the magnificent medieval monument that thousands flock to each year.

4. Óbidos, Portugal

41b81f20-

(Hemis/Alamy)

Whitewashed houses line Óbidos’s crooked cobblestone streets, where traditional restaurants serve octopus salad and the Portuguese drink ginjinha. The historic heart of the city is its 12th-century castle, which was converted into a medieval-inspired boutique hotel in the 1950s. Óbidos is particularly lovely in the summer, when leafy church squares abloom with wisteria and geraniums form the perfect backdrop to the ancient architecture.

5. Jerusalem

8c2be12b-

(Yadid Levy/Alamy)

Surrounded by the modern city, Jerusalem’s walled Old City includes the famous Church of the Holy Sepulchre. Visitors are also encouraged to walk the ramparts on the Tower of David and gaze at the Dome of the Rock and the Western Wall before making their way through the souk of the bustling Arab quarter.

Go behind the walls of the world's greatest walled cities.

More from Architectural Digest

The Best Hotels Around the World

7 Over-the-Top Celebrity Homes

The Best Beach Resorts for Your Spring Vacation

The World's Most Exclusive Private Clubs