One of the masterpieces of the medieval architecture of the ancient city is the residence of Shirvan governors – the Shirvanshahs' Palace Ensemble which has preserved its historic and architectural features up to date.

In the Middle Ages when Shemakhy was in the period of disturbances, Baku developed in a relatively quiet situation. It was known that the strong fortress walls had been built in Baku in XII (1138 -1139). After the earthquake that shocked Shemakhy, the capital was transferred to Baku and the Shirvanshahs' Palace was erected.

The Palace ensemble consists of 9 buildings: the Palace, the Divankhane (Court –House), the Dervish's Mausoleum, the Eastern Gate (Portal), the Palace mosque, the Key-Qubad mosque, the Palace Burial-Vault, the Hamam (bath-house)  and the ovdan (storage lake).

The complex consists of 3 courtyards with buildings towering above each other by 5.6 m. As the Palace is located in the area with rugged terrain it has no a single architectural plan. However, the buildings do not contrast with each other. Moreover, they group well. Looking from the different points one can clearly see that they are integrated part of the Palace ensemble.

All the buildings of the complex were built with local limestone ("badamdam"). The most ruined structure of the complex is the Palace building.

After killing of Farrukh  Yassar in a battle between the Shirvanshahs and the Sefevi in 1500 the Palace was plundered. It is not known who lived in the Palace after the Shirvanshahs.

Continued wars between Iran and Turkey for the rule over the Southern Caucasus were run also in the territory of Azerbaijan. Located at the crossing of the caravan routes Shirvan was attacked frequently and as a result, the Palace changed hands. This is proved with the Murad Gate built during the Turkish reign. There are the monuments in the Baku fortress dated from the Persian sway. During shelling Baku by troops of Peter I in 1723  north-east facade of the Palace mosque was damaged.

After the seizure of Azerbaijan by Russia on 10 February 1828 and transfer of the Palace structures to the headquarters staff the renovation was done here and the Palace has been converted into the headquarters. A lot of valuable buildings were demolished. Moreover, the Alexander Nevsky Church was planned to be constructed there. The Palace was destroyed and neglected at the end of XIX. On 5 October 1918 Decree by the Azerbaijan People Republic "On Inventory and Preservation of Art and Ancient Monuments Belonging to the Public, Institutions, and Individuals" was published. It was a step taken by the government to make the first inventory of ancient monuments. In 1932 the renovation works started in the Shirvanshah complex under Decree of the Azerbaijan Soviet of the People's Commissars. In 1937-38 archeological excavations were conducted in the Palace under the guidance of the archeologist  V.N.Leviatov and a lot of artefacts were found. For some periods a part of the Azerbaijan Folk Musem and the Museum of Religion were located in the Palace building. Since 1954 the Shirvansahs' Palace Complex has been converted into the State Historical-Architectural Reserve Museum. In 1960 a decision was made on the protection of the Palace as an architectural monument.

The Palace building.  The Palace is a two-storey building in the form of an irregular rectangle. For proper lightening of the Palace, its southern-east corner was slotted. Initially, there were 52 rooms in the Palace, 27 of them were on the 1st floor, 25 – on the 2nd floor. The rooms were symmetric. On the 2nd floor, the arched rooms for Shah and his family were located. The windows of the 2nd floor have a nice outlook over the sea. They are decorated with stone tracery (bar-pattern –shebeke).

As the residential building had no a dome, in 1932-34 when the first renovation started in the Palace it was covered with a flat roof and parquet was laid on its floor. Masonry was demolished on the windows built in the XIX century and a part of the stone floor was repaired. Inter-floor communications were kept through 2 narrow staircases and the stairs located in the floor of the octagonal hall.  As a result of the renovation, now there are 16 rooms in total on the II floor. The octagonal hall at the entrance is distinct among these rooms for its initial shape. The initial shape of the second octagonal room next to it has been preserved partly. Its arched roof was replaced with the flat roof. The rest 14 rooms have also been rehabilitated; however, they are not so interesting in terms of architecture. The magnificent main entrance is in the western wall of the building. The magnificent portal which represents all elements of Azerbaijan architecture of the XV century and has no any decorative element captures attention. There is a deep niche on the right and the left sides of the entrance.

Divankhana.   The Divankhana complex is situated in the upper courtyard and its northern corner adjoins the residential building. The Divankhana consisted of 8 octagonal rotundas covered with the twelve-sided dome. It is connected with the octagonal hall through the open porch. The pointed arcade of the porch rest on the 9 columns which have specific capitals and pedestal.  The arcade of the porch surrounding the courtyard is of the same form. On the outer side of the arches are a stone with the image of a dove symbolising freedom and 2 stone gutters. The building was used as an assembly room and court-room. Also, the possibility may not be denied that Shirvanshah Farrukh Yasar built the Divankhana complex as a mausoleum for himself.    However, the construction had not been finished. The traces on the columns show that formerly they were decorated with fine stone bas-relief. The pillared place was intended for meetings of the distinguished feudals. The Divankhana has 2 entrances from the upper courtyard and the street. The rotunda also has 2 entrances. The western entrance is distinct for its tall and delicately worked portal. The surface of the portal was decorated with the fig and vine leaves specific to the characteristic Apsheron flora, the ornament resembling the oriental carpet decoration and carving 3-5 cm depth. The portal, the ribbed semidome rest on the 7-row stalactic belt. There are two hexagonal medallions in the portal frame, leftward within them, six diamonds making up the geometric pattern in form of rosette are seen. Two diamonds have inscriptions: "There is no god but Allah", another one: "Muhammad is a messenger of Allah", the last one: "Ali is close to Allah".

12 diamonds are in the left hexagon. 6 of them has the inscription "There is only one Allah", the other 6: "Mohammad". The internal passage to the rotunda next to the portal is also marked with nice ornaments. Above the ornaments, 10 suras from Quran (Yunus Sura 25, 26, 27 ayahs) were inscribed. "Most –High and Most-Pure Allah said: Allah invites the people to paradise and puts those he loves on the right track, shows them the right way.  Requital and reward are for those who do good and blessing deeds. They are not covered by the veil of sin and consequently they will not be unhappy, they will be translated to Heaven, will stay there forever. Truth Allah says to you."

Artistic effects are expressed here with the lights and darks depending on the specifics of the masonry. One of the courses is horizontal, the other one is vertical that ensures various shading of the stones.  The similar construction of the walls is traceable in all buildings of the ensemble.

There are hexagonal medallions on the rib of the rotunda arch, with name "Ali" inscribed on their stones in 3 convex and 3 concave forms. There are no ornaments on the doorways and the entrance is incomplete while there is frame prepared for inscription. It is supposed that the construction of the building was suspended in the period of wars in 1500-1501. The central hall if the rotunda has no ornamental finishing, its sides still remain at the place of the doorway beams and pointed grooves. Quadrangle staircase in the middle of the central hall provides a connection with the basement. Different opinions are expressed regarding their purpose. It is also supposed that it may be a sepulchre.

A rectangle corridor is on the lower part in front of the central hall. The corridor is ended with the magnificent portal on the one side, and the two entrances from the small southern door –on the other side. A small service room is in the eastern part of the corridor. 5 wells of different depth (3-15 meters) are in the Divanakhana courtyard. Probably they were used for food storage.

The perfection of the architectural style of the Divankhana, high grade of ornamentation shows that the Azerbaijani nation has great architectural heritage. Central place among the portal compositions existing in the Shirvan belongs to the Divankahana and the Shirvanshahs' sepulchre portal. For its beauty and fineness, the Divankhana is considered to be a masterpiece of the similar architectural monuments either in Azerbaijan or in the Middle East.

Dervish Tomb. The tomb named by the people  "Dervish Tomb" and located in the southern part of the courtyard takes the central place in the middle yard. Some experts allege that it belongs to Seyid Yahya Bakuvi.  Some experts groundlessly attribute all the monuments existing in the lower courtyard, including the Dervish Tomb, to the Khanaqah buildings complex.

According to historians, Seyid Yahya Bakuvi I was one of the court scientists in the Khaliullah I Period. He was born in Shamakhy. In his youth, he was a follower of the sheykh Sadraddin sect. Upon the death of sheykh Sadraddin, he came to Baku and lived here to the end of his life. According to some authors, he died in 862 Anno Hegirae. 30 works by Seyid Yahya Bakuvi have survived to our days. They are of Sufism- mystic nature and are kept in the Muradiyya Library in the town of Manisa, Turkey.

The Tomb is within the complex where the Keyqubad Mosque foundation is located. It should be noted that there was neither an inscription indicating to whom it belonged nor a headstone within the tomb. The tomb is notable for its fine structure. The small octagonal tomb has been worked with high workmanship.  To enrich its exterior the pyramidal surfaces of the dome are slightly convex. The height of the tomb is 7.5 m. The tomb consists of the underground and ground parts. The masonry of the walls was done with dark and light stones and due to their rotation, the surfaces look like the coloured. The tomb has three windows decorated with stone tracery.

Epigraphy researcher Meshedikhanim Nemat supposes that the dervish buried within the Shirvanshahs' Palace Complex at the place which up today is named by the people as the Dervish Tomb (Mausoleum) as the person who had written the inscription of the "Diri Baba" near Maraza  in 805 Anno Hegira (1402-03) during Shirvanshah Sheyh Ibrahim period (1382-1417). Such octagonal tombs are widespread in the Azerbaijan architecture (Shamakhy, Agdam, Agsu, Khachmaz, Quba etc). However, the Dervish Tomb (Mausoleum)is the finest specimen among these tombs.

The Keyqubad Mosque. The Keyqubad Mosque was a mosque-medrese building adjoining the Dervish Tomb. The Tomb is located to the east of the mosque. The Mosque comprises a praying hall and a small corridor before it. Formerly there were four columns in the centre of the hall to support the dome. A. Bakikhanov wrote about teaching and praying by Bakuvi: "The cell where he prayed, the school where he taught and his tomb are there – in the mosque". According to researcher S. Ashurbeyli, Keyqubad was the grandfather of  Sheyh Ibrahim. Shirvanshah Keyqubad was in power from 1317-43. Only the remains of the foundation and several safe arches fo the Keyqubad Mosque survive now.

The Eastern Gate Portal. The only structure dated back to the XVI AD is the Murad Gate. 2 medallions on the upper frame of the Murad Gate Portal contain the following inscriptions: "This building was built in the period of the Great and Fair Sultan III Murad to order by the Grand Rejeb Bakuvi in 994 (1585-86)".

The inscription on wall niches of the Portal contains the name of architect Amirshah from Tebriz. With its general, artistic and decorative composition the portal is congruous with the Divankhana and the Mausoleum. However here the quality of construction techniques and the stones is much lower. Style purity of the Azerbaijan ornamental art is violated here. While the architect tried to maintain the stability, and harmony of the ensemble he failed to avoid worsening of high architectural quality specific to that period.

The Shirvanshahs' Mausoleum. 2 buildings of the complex, the Mausoleum, and the Palace, are located in the area of the lower courtyard. The lower courtyard is separated from the other one with the circular close wall. Looking at the mausoleum from the upper point one can see that it is decorated with carven starts and crown with the hexagonal dome. Blue glazed tiles were placed in the star cuts on the dome when it was built.

The inscription on the entrance indicates the date and the name of this nice building. The inscription says: "Defender of the faith, a man of the prophets, the great sultan Shirvanshah Khaliullah, let his reign and power last eternally, ordered to build this bright building for his mother and his 7-year son,  Allah rest them in Paradise, the year of 839" (1453 -36). The medallion embellishing the portal contains the inscription which can only be read through a mirror: "Allah, architect Mohammad Ali". We know that it was prohibited for architects to inscribe their names on the buildings". For this reason, the master has encrypted his name in such a manner. This is the evidence of intelligence and inventiveness of the architect and his proper performance. This inscription was read by the prominent orientalist A. A. Alasgarzadeh in 1954. The others inscription were taken from Quran suras.

The portal passage has rich ornaments. On the top of the portal, 92 aya of the 12th  sura of the Quran was engraved. The inscription says:" The Highest and the Great Allah said: today Allah will forgive you because he is all-merciful". The name "Ali" is inscribed 12 times in the medallion on the plain entrance.  

There is a corridor at the entrance of the mausoleum covered with the octagonal dome. On its left and right there are 2 service rooms. The square main hall consists of the central part and the pointed arches placed on its four sides. The central part of the hall is covered with a dome. Small square rooms are in the northern and southern corners of the hall.

The entrance contains an inscription indicating that it was built for the Shirvanshalh Khakiullah's mother and son. However other members of the Shirvanshahs' family were buried here. Stone slabs were found below the floor demolished during excavations. It was established that seven slabs were grave-tones, bones were found only in 5 tombs. 2 tombs did not contain bones.

According to odes, eulogies and divans (selected poems) by Badr Shirvani, the Poet Laureate in the Shirvanshahs' Palace, and artefacts revealed in the tombs, the names of those who lie here were identified and clarified.

In tomb I, Shirvanshah's 7-year old son Farrukh Yamin (1435-42) was buried.  Tomb II belonged to an aged woman, probably, Shirvanshah's mother. The name of the Shirvanshah mother was Bike, she was an esteemed woman, and died in 839 h. (1435-36).

Tomb III belonged to a prisoner of Qara Yusif, after his death, she married the Shirvanshah Shahrukh, her name was Khanika.

In tomb IV lies the Shirvanshah's 2-year old son Sheykh Salah (1443-45).

Tomb V belonged to 19-aged  Ibrahim II (1432).

Opposite to the entrance, a big skeleton was found 2m 10 sm in height. The tomb is supposed to belong to Khaliullah I.

The Palace Mosque. The Palace mosque is located at the lower court close to the mausoleum. The Mosque is 22 m in height. The inscription belting the minaret says: "The erection of the minaret was ordered by the Great Sultan Khaliullah. Allah extends his reign and power years.  845 h" (1441 -42).

A well and a small pool for washing and ablution before entering the mosque are on the north of courtyard.

The architectural form of the mosque is very simple. Its entrance portal is unembellished, but the minaret attracts attention for its fineness and beauty. Stalactites supporting its porch and an inscription belt at the base are made with great skill.  The minaret is crowned with a ribbed dome. The sides of the porch are encircled with a stone balustrade decorated with carving like in other large mosque minarets. The stone balustrade destroyed later during the bombardment by the Russian army in XIX was replaced with an iron rail.

The mosque is entered through the simple doors from the north, east and east.  The eastern door was for the shah and his family, the northern one - for men, the western one – for women. The praying hall of the domed mosque consists of a central part and 4 pointed niches connected with each other. A mehrab crowned with a ribbed semidome is embellished with fine stalactites. A small room vaulted is in the north-east corner of the mosque which used to be a praying room for women. An ordinary niche serves as its mehrab. Big pots built in the wall in the upper corner of the central hall and open towards the hall reinforce sound in such a manner that the voice of a mullah was heard also in the women room. A staircase leading to another small room through the slots of the niches is in the wall behind the pulpit. A tracery before the windows embellishes this building.

The Palace Hamam. The Palace Hamam is located in the lower courtyard of the Complex. Like all hamams in the Icherisheher this hamam also was built under the ground in order to keep the regular temperature condition.  The thickness of the ground layer gradually increased and has completely covered it. The hamam was revealed in 1939 accidentally, one its part was cleaned in 1953, it was conserved in 1961. According to the walls survived till our days, it can be stated that its rooms were domed. The hamam was lightened through the slots in the dome. Such hamam systems are typical for Baku and Absheron. The left part of the hamam has been rehabilitated, the right part has better held its shape.

Water to hamam flowed from an ovdan (storage lake) near the wall to a boiler room, then was distributed to rooms through special built ways. There were also so called "secret" rooms for undressing or individual bathing. The end of the pipe laid in walls to the rooms is seen in the arch.

In the right corner of the are one large and two small domed rooms. Probably, these rooms covered with glazed tiles belonged personally to the shah.

Ovdan. Ovdan is built in the form of a portal, many stairs lead to the storage from there. Connection existed between the ovdan and hamam is seen from a vestibule. Water to ovdan was supplied through kehriz (underground pipes)  from a fine example of monumental and decorative arts of medieval Azerbaijan.