In 1945 an Arab peasant named Muhammed Ali and his brothers discovered a jar at the base of a cliff near the town of Nag Hammadi in Upper Egypt. Inside the jar were 13 leather-bound papyrus books (codices). The manuscripts were immediately caught in a web of family rivalries, black market trading, and international intrigue, but finally they resurfaced and began to be studied by scholars. The Nag Hammadi "library," as it is often called, turned out to be a treasure trove of ancient Gnostic texts.

The 13 codices contained 52 tractates (individual writings—Coptic translations of Greek texts from the second and third centuries A.D. Out of those 52 tractates (which included a partial translation of a very short passage from Plato's Republic), 40 were Gnostic writings that scholars had never seen before. Most are secret apocalypses and/or "revelation" discourses. The collection also includes gospels (the most famous of which is the Gospel of Thomas), acts, and epistles. They combine pagan, Jewish, and Christian ideas and reflect the two major Gnostic schools of thought, the Sethian school and the Valentinian school. Many of the texts emphasize the Apostle Thomas. (This is now often called Thomasine Christianity.)

The origin of the collection remains somewhat mysterious, but most likely the texts were buried by priests and monks from a nearby monastery that had been founded in the early fourth century by Pachomius, the "father" of communal monasticism. The priests may have collected them in order to refute them or, just as likely, to seek some spiritual benefit or wisdom from them. The burial was probably prompted by Bishop Athanasius' Easter letter in 367, in which he condemned heretical and non-canonical books.

The Nag Hammadi collection is not the only discovery that has revolutionized our knowledge of Gnosticism. The Berlin Gnostic Codex, discovered in 1896, was not published until 1955 (after the Nag Hammadi discovery) due to the world wars. Its most famous unique text is the Gospel of Mary. In 2006 the Gnostic Gospel of Judas was published; it is one of four documents in the Codex Tchacos (found in the 1970s). Another previously unknown document from this codex, The Book of Allogenes, was published in 2007.

Before these discoveries, most of what we knew of Gnostic groups came from critiques of them in anti-heretical writings by the church fathers. Now anyone wishing to know what the Gnostics really believed has a wealth of material to read.