The history of libraries began with the first efforts to organize collections of documents. Topics of interest include accessibility of the collection, acquisition of materials, arrangement and finding tools, the book trade, the influence of the physical properties of the different writing materials, language distribution, role in education, rates of literacy, budgets, staffing, libraries for targeted audiences, architectural merit, patterns of usage, and the role of libraries in a nation's cultural heritage, and the role of government, church or private sponsorship. Computerization and digitization arose from the 1960s, and changed many aspects of libraries.

Early libraries

The first libraries consisted of archives of the earliest form of writing – the clay tablets in cuneiform script discovered in Ebla in present-day Syria; and in temple rooms in Sumer, present-day Iraq. About an inch thick, tablets came in various shapes and sizes. Mud-like clay was placed in the wooden frames, and the surface was smoothed for writing and allowed to dry until damp. After being inscribed, the clay dried in the sun or, for a harder finish, was baked in a kiln. For storage, tablets could be stacked on edge, side by side, the contents described by a title written on the edge that faced out and was readily seen. The first libraries appeared five thousand years ago in Southwest Asia's Fertile Crescent, an area that ran from Mesopotamia to the Nile in Africa. Known as the cradle of civilization, the Fertile Crescent was the birthplace of writing, sometime before 3000 BC. (Murray, Stuart A.P.) These archives, which mainly consisted of the records of commercial transactions or inventories, mark the end of prehistory and the start of history.Renfrew, Colin (2008) Prehistory The Making of the Human Mind, New York: Modern Library.

Things were very similar in the government and temple records on papyrus of Ancient Egypt. The earliest discovered private archives were kept at Ugarit; besides correspondence and inventories, texts of myths may have been standardized practice-texts for teaching new scribes.

Over 30,000 clay tablets from the Library of Ashurbanipal have been discovered at Nineveh, providing modern scholars with a wealth of Mesopotamian literary, religious and administrative works. Among the findings were the Enuma Elish, also known as the Epic of Creation,"Epic of Creation," in Dalley, Stephanie. Myths from Mesopotamia. Oxford, 1989; pp. 233–81 which depicts a traditional Babylonian view of creation, the Epic of Gilgamesh,"Epic of Gilgamesh," in Dalley, Stephanie. Myths from Mesopotamia. Oxford, 1989; pp. 50–135 a large selection of "omen texts" including Enuma Anu Enlil which "contained omens dealing with the moon, its visibility, eclipses, and conjunction with planets and fixed stars, the sun, its corona, spots, and eclipses, the weather, namely lightning, thunder, and clouds, and the planets and their visibility, appearance, and stations," Van De Mieroop, Marc (2007). A History of the Ancient Near East ca. 3000–323 BC. Oxford, UK: Blackwell Publishing. p. 263 and astronomic/astrological texts, as well as standard lists used by scribes and scholars such as word lists, bilingual vocabularies, lists of signs and synonyms, and lists of medical diagnoses.

The tablets were stored in various containers, such as wooden boxes, woven baskets of reeds, or clay shelves. The "libraries" were cataloged using colophons, which are a publisher's imprint on the spine of a book, or in this case, a tablet. The colophons stated the series name, the title of the tablet, and any extra information the scribe needed to indicate. Eventually, the clay tablets were organized by subject and size. Due to limited bookshelf space older tablets were removed, which is why some were missing from the excavated cities in Mesopotamia.Weitemeyer, M. (1956). Archive and library technique in ancient Mesopotamia. Libri: International Journal of Libraries, 6(3). 217–238.

According to the legend, mythical philosopher Laozi was the keeper of books in the earliest library in China, which belonged to the Imperial Zhou dynasty.Mukherjee, A. K. (1966). Librarianship: Its Philosophy and History. Asia Publishing House. p. 86 Also, evidence of catalogs found in some destroyed ancient libraries illustrates the presence of librarians.

Classical period Persia at the time of the Achaemenid Empire (550–330 BC) was home to some outstanding libraries that were serving two main functions: keeping the records of administrative documents (e.g., transactions, governmental orders, and budget allocation within and between the Satrapies and the central ruling State)Rajabi, Parviz. 1381. The Lost Millenia, Vol 3, Toos Publication, and collection of resources on different sets of principles e.g. medical science, astronomy, history, geometry, and philosophy.

In 1933 University of Chicago excavated an impressive collection of clay tablets in Persepolis that indicated the Achaemenids' mastery of recording, classifying, and storing a broad range of data. This archive is believed to be the administrative backbone of their ruling system throughout the vast territory of Persia. The baked tablets are written in three main languages: Old Persian, Elamite, and Babylonian. The cuneiform texts cover various contents from records of sales, taxes, payments, treasury details and food storage to remarkable social, artistic and philosophical aspects of an ordinary life in the Empire. This priceless collection of tablets, known as the Persepolis Fortification Archive, is property of Iran. A part of this impressive library archive is now kept in Iran while a major proportion is still in the hands of the Chicago Oriental Institute as a long-term loan for the purpose of studying, analyzing, and translating.

Some scholars believed that massive resources of archives and resources in different streams of science were transferred from Persia's main libraries to Egypt upon the conquest of Alexander III of Macedon. The materials were later translated into Latin, Egyptian, Coptic, and Greek and shaped a remarkable body of science in the Library of Alexandria. The materials that were not transferred are said to have been set on fire and burnt by the Alexander militants.

Less historically tested claims have also reported a sizeable building in Isfahan, Jey, named Sarouyeh, which was being used by Iran's ancient dynasties to store collections of precious books and manuscripts. At least three Islamic scholars, al-Biruni, Abu Ma'shar al-Balkhi, and Hamza al-Isfahani, have named this hidden library in their works. The same references claimed that this treasury was discovered in early Islam and the valuable books were selected, bound, and transferred to Baghdad for later reading and translating. As reported by observers, at the time of unearthing the archive, the manuscripts' alphabet was entirely unknown to that ordinary people.Abu Rayhan Al Birouni, The Chronology of the Ancient Nations, Translated and edited by Eduard Sachau, 2004 reprint: Kessinger Publishing, Homayoun Farrokh, Rokn Aldin, The History of Books and Libraries in Iran, Honar va Mardom Magazine, 1347

The Library of Alexandria, in Egypt, was the largest and most significant great library of the ancient world.Cosmos: A Personal Voyage, Sagan, C 1980, "Episode 1: The Shores of the Cosmic Ocean" It flourished under the patronage of the Ptolemaic dynasty and functioned as a major center of scholarship from its construction in the 3rd century BC until the Roman conquest of Egypt in 30 BC. The library was conceived and opened either during the reign of Ptolemy I Soter (323–283 BC) or during the reign of his son Ptolemy II (283–246 BC).Phillips, Heather A., "The Great Library of Alexandria?" . Library Philosophy and Practice, August 2010 An early organization system was in place at Alexandria (compare the Pinakes).

The Library of Celsus in Ephesus, Anatolia, now part of Selçuk, Turkey was built in honor of the Roman Senator Tiberius Julius Celsus Polemaeanus (completed in AD 135) by Celsus' son, Tiberius Julius Aquila Polemaeanus (consul, 110). The library was built to store 12,000 scrolls and to serve as a monumental tomb for Celsus. The library's ruins were hidden under the debris of the city of Ephesus which was deserted in the early Middle Ages. In 1903, Austrian excavations led to this hidden heap of rubble that had collapsed during an earthquake. The donator's son built the library to honor his father's memory and construction began around 113 or 114.Strocka, Volke, M. (2003). The Celsus Library. Ancient libraries of Anatolia: libraries of Hatusha, Pergamon, Ephesus, Nysa.(Ankara): Middle East Technical University Library, 2003, pp. 33–43. Unfortunately, the library was subject to both a fire and an earthquake that destroyed the majority of the building. Despite modern reconstructive efforts, only the façade (the front of the building) was able to be rebuilt.Cartwright, M. (2019, July 22). Library of Celsus. World History Encyclopedia. Retrieved from https://www.worldhistory.org/Library_of_Celsus/

Private or personal libraries made up of written books (as opposed to the state or institutional records kept in archives) appeared in classical Greece in the 5th century BC. The celebrated book collectors of Hellenistic Antiquity were listed in the late 2nd century in Deipnosophistae. All these libraries were Greek; the cultivated Hellenized diners in Deipnosophistae pass over the libraries of Rome in silence. By the time of Augustus there were public libraries near the forums of Rome: there were libraries in the Porticus Octaviae near the Theatre of Marcellus, in the temple of Apollo Palatinus, and in the Ulpian Library in the Forum of Trajan. The state archives were kept in a structure on the slope between the Roman Forum and the Capitoline Hill.

Private libraries appeared during the late republic: Seneca inveighed against libraries fitted out for show by illiterate owners who scarcely read their titles in the course of a lifetime, but displayed the scrolls in bookcases (armaria) of citrus wood inlaid with ivory that ran right to the ceiling: "by now, like bathrooms and hot water, a library is got up as standard equipment for a fine house (domus)".Seneca, De tranquillitate animi ix.4–7. Libraries were amenities suited to a villa, such as Cicero's at Tusculum, Maecenas's several villas, or Pliny the Younger's, all described in surviving letters. At the Villa of the Papyri at Herculaneum, apparently the villa of Caesar's father-in-law, the Greek library has been partly preserved in volcanic ash; archaeologists speculate that a Latin library, kept separate from the Greek one, may await discovery at the site.