The legendary fortress of Gulistan in Shamakhi is one of the greatest monuments of Azerbaijani statehood. It received its name due to the scenic area in which it was located (“Gulistan” - means “flower garden”). Built in the 8th-9th centuries at the top of a 200-meter rocky mountain in the north-west of Shamakhi, this powerful fortification for nine centuries served as one of the main strongholds of the Shirvanshah state. For its inaccessibility, the Gulistan fortress was popularly nicknamed the Maiden's Fortress (Giz Galasi). During the invasions of foreign invaders, the inhabitants of Shamakhi for centuries found protection behind the walls of the fortress. Its fortifications took the blows of Arab, Seljuk, Mongol and Ottoman troops. The territory of Gulistan fortress was enclosed by powerful walls with numerous round and quadrangular towers. The winding road led from the bottom of the fortress to the citadel on the top of the mountain, girded with a solid ring of fortified walls.
In the 12th–13th centuries, the fortress was thoroughly rebuilt and strengthened. In the 14th-15th centuries Gulustan fortress serves as one of the residences of the khans of Shirvan. During the archaeological excavations in 2011, an underground passage built during the times of the Shirvanshahs state (IX-XVI centuries) was discovered in the fortress. According to historians, this tunnel was intended to deliver sudden blows to the enemy from the rear, and also so that Shirvanshah could leave the fortress unnoticed if it was taken. Equipped with steps carved into the rock, the underground corridor led from the fortress to the bank of the Zogalavay river, which flows nearby. Also in the excavation area were found the remains of a bridge.
At the beginning of the 16th century, the Gulistan fortress was captured by the Safavid ruler Tahmasib I and destroyed. Having put an end to the existence of the state of Shirvanshahs, the Shah destroyed the symbol of independence of Shirvan - the fortress of Gulistan. Then, during the Safavid-Ottoman wars, the fortress conquered by the Ottomans was restored, and the Turkish garrison was located there.
The fortress of Gulistan existed until the end of the 16th century. The structure suffered greatly not only from the wars, but also from numerous earthquakes, and only its ruins have reached us. They can be seen at the entrance to Shamakhi, as evidence of the rich historical past of the city. From the top of the hill, where the remains of the fortress are located, a breathtaking view of the city and surroundings opens up.