In 1750,the donjon was burned to the ground because of lightning . The Inner Palace was also destroyed by fire in 1788. Tokugawa Yoshinobu, the fifteenth and the last shogun of the Tokugawa Shogunate, returned the sovereignty to the emperor in 1867. Nijo Castle was offered to the imperial family. In 1868, the Imperial Cabinet was installed in the castle . The castle changed its name to Nijo Detached Palace in 1884. In 1939, the palace was donated to the city of Kyoto.