In the southern courtyard, next to the palace, stands a mausoleum, built in the second half of the 15th century, called the mausoleum of the "dervish" and known as the burial of the court scholar Khalil Ili Seyid Yahya Bakuvi, who was engaged in medicine, mathematics, and astrology. The mausoleum has an octagonal body, which completes the pyramidal tent. The interior of the mausoleum consists of an underground crypt where the tombstone of Bakuvi is located, and a camera above it. Small octagonal volume of the mausoleum turns into a drum covered with a dome. On the sides of the mausoleum there are three small windows carved into solid slabs of limestone, and, like in the old days, they are through-through stone gratings, consisting of multi-beam stars. The archway in the northern part connects the mausoleum with an older mosque. According to Abbaskuli aga Bakikhanov, "the cell where he prayed [Bakuvi], the school and the grave that are under the mosque named after him, still exist today".
