Based on the small groupings of papyri that have been found in burials, Ancient Egyptians are believed to have collected texts as part of elite possessions. Inscriptions and manuscripts also contain numerous references to groups of books as the "House of Books." There are no architectural remains for any large ancient Egyptian libraries, but they most likely would have been in the palaces and principal temples. At the Temple of Edfu, a chamber is inscribed with a catalog of books, but due to its size and location, it was probably used to house books regularly used for temple rituals.
During the Ptolemaic period, Ptolemy the First Soter ordered the establishment of what became the Library of Alexandria. Demetrius of Phalerum put together the central collection for the library and Ptolemy the Second Philadelphius sponsored the completion of the work. Later kings were eager to increase the collection. Ptolemy the Third, for example, required all incoming travelers to hand in any books. If they were not already part of the library, the books would be kept while the owners received cheap copies. At its peak, the Library probably held around 700,000 scrolls, equivalent to 100-125,000 printed bound books. By the mid-third century BC, the original building became too small and about 42,800 copies and incomplete manuscripts were moved to the Serapeum.
Nearly 40,000 books in the Library of Alexandria were burned in fires resulting from the conflicts between Caesar and Cleopatra the Seventh in 48 BC. Although Antony compensated the queen with 200,000 scrolls from Pergamum, the Library of Alexandria was destroyed sometime by the end of the third century BC during the power struggles of the Roman Empire. The Serapeum, or "Daughter Library," was judged to support pagan doctrine and destroyed by Theophilus, the Bishop of Alexandria, based on a decree by Theodosius in 391 AD that forbade all non-Christian religions.
The Christian population in Egypt had access to the civic libraries established during the Ptolemaic and Roman times and church libraries, often located in monasteries. The library in the White Monastery of Saint Shenouda the Archimandrite at Sohag might have been the greatest in Coptic Egypt, but it is now scattered. Hundreds of parchment and papyrus fragments have been found at the site of the monastery of Saint Apollo, which also might have housed a library.
The Muslims were great book collectors and libraries flourished under Islam, which promoted institutions of learning. In Egypt, and especially Cairo, large schools and mosques held libraries that were accessible to scholars in addition to the private libraries maintained by princes, nobles, and merchants. Each library had a catalog of its collection and employees who performed the job of the present-day librarian, in addition to scribes, book binders, and book handlers. In AH 395 (AD 1004), the Fatimid ruler Al-Hakim established an institute of learning called the Dar al-ilm, or House of Knowledge. He donated books on a wide range of subjects, encouraged scholars to teach there, and funded a support staff and furnishings. By the eleventh century, this research foundation was said to have held over one million volumes. In a fate similar to the Library of Alexandria, it was destroyed during the period of instability brought on by the invasions of the Crusaders and Mongols.