In the mythology of the ancient Egyptians, APEP (sometimes known as Apophis) was the ancient Egyptian demon-deity who embodied utter chaos (ı͗zft in Egyptian) and as such, was considered the opponent of light and Ma'at (order/truth). He appears in Egyptian art as a giant sinister serpent. Since Ra was the god of the sun and upholder of truth, Apep was viewed as his greatest enemy and thus was given the title Enemy of Ra, and also "the Lord of Chaos".
As the personification of all that was evil, Apep was also known as the "Serpent from the Nile" and "Evil Lizard."
Some elaborations said that he stretched 16 yards in length and had a head made of flint.
According to legend, storytellers would say that every day Apep lay just below the horizon, appropriately making him a part of the underworld. In some stories Apep waited for Ra within a western mountain called Bakhu, where the sun set, and in others Apep lurked just before dawn, in the Tenth region of the Night. The wide range of Apep's possible location gained him the title "World Encircler." It was thought that his terrifying roar would cause the underworld to rumble.
Myths sometimes say that Apep was trapped there, because he had been the previous chief god overthrown by Ra, or because he was extravagantly evil and had been imprisoned there for eternity.
It was implied that Apep used a magical gaze to overwhelm Ra and his entourage as he made his way through the underworld on his glorious barge each night. Ra was assisted by a number of defenders who traveled with him, including Set and possibly the Eye of Ra. Apep's slithering movements and abrupt strike-attacks were thought to cause earthquakes, and his battles with Set may have been meant to explain the origin of thunderstorms. In some accounts, Ra himself defeats Apep in the form of a cat, often shown cutting him up.
Ancient priests of Ra had instructions for making special wax models, or small drawings, of the serpent, which would be spat on, mutilated and burnt, while reciting spells that would slaughter Apep. Fearing that even the image of Apep could give power to the demon, any rendering made would always include another deity alongside it to subdue the monster...
Ra was worshipped, and Apep worshipped against. Ra's victory each night was thought to be ensured by the prayers of the Egyptian priests and worshippers at temples. The Egyptians practiced a number of rituals and superstitions that were thought to ward off Apep, and aid Ra to continue his journey across the sky.
In an annual rite, called the Banishing of Chaos, priests would build an effigy of Apep that was thought to contain all of the evil and darkness in Egypt, and burn it to protect everyone from Apep's evil for another year, in a similar manner to modern rituals such as Zozobra.
The Egyptian priests had a detailed guide to fighting Apep, referred to as The Books of Overthrowing Apep (or the Book of Apophis, in Greek). The chapters described a gradual process of dismemberment and disposal, and include:
Spitting Upon Apep
Defiling Apep with the Left Foot
Taking a Lance to Smite Apep
Taking a Knife to Smite Apep
Putting Fire Upon Apep
In addition to stories about Ra's winnings, this guide had instructions for making wax models, or small drawings, of the serpent, which would be spat on, mutilated and burnt, whilst reciting spells that would kill Apep. Fearing that even the image of Apep could give power to the demon any rendering would always include another deity to subdue the monster.
As Apep was thought to live in the underworld, he was sometimes thought of as an Eater of Souls. Thus the dead also needed protection, so they were sometimes buried with spells that could destroy Apep. The Book of the Dead does not frequently describe occasions when Ra defeated the chaos snake explicitly called Apep. Only BD Spells 7 and 39 can be explained as such