The name was given to the 'book' by Maspero, and refers to the gates guarded by gatekeepers that divide the different phases of the night from each other.
In common with the Amduat, the Book of Gates has the theme of the sun's journey and the realm of the dead, the division into twelve hours (or departments) of the underworld and the three registers. In addition, it has a judgement scene with cryptographic texts and a final illustration. The central judgement scene, which takes place at the end of the fifth hour, is painted in the middle of the wall above the sarcophagus in the tomb of Horemheb. The words of the deceased are 'weighed' in the judgement hall before Osiris and the judges, the blessed are then fed, whereas sinners are destroyed.
It is not certain when the Book of Gates first appeared; although some scholars suggest a date in the Middle Kingdom or even the 1st Intermediate Period, it was probably composed under Amenhotep III and was first introduced into a tomb by Horemheb, partly to replace the Amduat. Henceforth the two oldest Books of the Underworld appear together in most of the royal tombs of the 19th and 20th Dynasties. There is a complete example on the sarcophagus of Sethos I.
After the New Kingdom the Book of Gates is no longer found on tomb walls, but still appears in fragments on the papyri and sarcophagi of non-royal persons from the 21st Dynasty. Only in the 26th Dynasty does the Book of Gates reappear together with other Books of the Underworld in the richly decorated tomb of Petamenophis. In the Late Period, when coffin decoration was undergoing a new Golden Age inspired by the royal tombs and sarcophagi of the New Kingdom, private persons began to use the judgement scene in particular, as well as part of the first hour. The final illustration, which depicts the end of the journey through the night, had already begun to appear in mythological papyri and in the Books of the Dead of the 21st Dynasty.