Apep (pron.: // or //) or Apophis (pron.: //; Ancient Greek: Άποφις; also spelled Apepi or Aapep) was an evil god in ancient Egyptian religion, the deification of darkness and chaos (ı͗zft in Egyptian), and thus opponent of light and Ma'at (order/truth), whose existence was believed from the 8th Dynasty (mentioned at Moalla) onwards. His name is reconstructed by Egyptologists as *ʻAʼpāpī, as it was written ꜥꜣpp(y) and survived in later Coptic as Ⲁⲫⲱⲫ Aphōph.
Ra was the solar deity, bringer of light, and thus the upholder of Ma'at. Apep was viewed as the greatest enemy of Ra, and thus was given the title Enemy of Ra.
As the personification of all that was evil, Apep was seen as a giant snake/serpent, or occasionally as a dragon in later years, leading to such titles as Serpent from the Nile and Evil Lizard. Some elaborations even said that he stretched 16 yards in length and had a head made of flint. It is to be noted that already on a Naqada I (ca. 4000 BC) C-ware bowl (now in Cairo) a snake was painted on the inside rim combined with other desert and aquatic animals as a possible enemy of a deity, possibly a solar deity, who is invisibly hunting in a big rowing vessel.
Also, comparable hostile snakes as enemies of the sun god existed under other names (in the Pyramid Texts and Coffin Texts) already before the name Apep occurred. The etymology of his name (ꜥꜣpp) is perhaps to be sought in some west-semitic language where a word root ꜣpp meaning 'to slither' existed. A verb root ꜥꜣpp does at any rate not exist elsewhere in Ancient Egyptian. (It is not to be confused with the verb ꜥpı͗/ꜥpp: 'to fly across the sky, to travel') Apep's name much later came to be falsely connected etymologically in Egyptian with a different root meaning (he who was) spat out; the Romans referred to Apep by this translation of his name. Apophis was a large golden snake known to be miles long. He was so large that he attempted to swallow the sun every day.
Set eventually became thought of as the god of evil, and gradually took on all the characteristics of Apep. Consequently, Apep's identity was eventually entirely subsumed by that of Set.