A hag is a wizened old woman, or a kind of fairy or goddess having the appearance of such a woman, often found in folklore and children's tales such as Hansel and Gretel. One of the most infamous hags in mythology is Baba Yaga from Slavic mythology.
Hags are often seen as malevolent, but may also be one of the chosen forms of shapeshifting deities, such as the Morrígan or Badb, who are seen as neither wholly beneficent nor malevolent. Although many Hags are neutral rather than evil they have become heavily associated with witchcraft and evil, to the point the two are often interchangeable (much like how Ogres and Giants have become somewhat merged in modern times).
Traditionally a Hag was seen as a spirit or goddess in the form of a hideous old woman and often had power over the elements or magic, thus gained fear and respect in equal lengths by the superstitious, who would try to either appease the more benevolent of these spirits or ward off the more malicious.
A hag, or "the Old Hag", was a nightmare spirit in English and anglophone North American folklore. This variety of hag is essentially identical to the Old English mæra, a being with roots in ancient Germanic superstition, and closely related to the Scandinavian mara. According to folklore, the Old Hag sat on a sleeper's chest and sent nightmares to him or her. When the subject awoke, he or she would be unable to breathe or even move for a short period of time. In the Swedish film Marianne, the main character suffers from these nightmares. This state is now called sleep paralysis, but in the old belief the subject had been "hagridden". It is still frequently discussed as if it were a paranormal state.
Hags were likely inspired by pagan beliefs dating back almost as far as human history and probably embody part of the ancient concept of a "Goddess". As Christianity spread, however, Hags would inevitably become more demonized (along with many of the "fairies"), giving rise to tales of grisly old demon-witches with a taste for human flesh and so on.
Many stories about hags seem to have been used to frighten children into being good. The Northern English Peg Powler, for example, was a river hag who lived in the River Tees and had skin the colour of green pond scum. Parents who wanted to keep their children away from the river's edge told them that if they got too close to the water she would pull them in with her long arms, drown them, and sometimes eat them.
Hags as sovereignty figures abound in Irish mythology. The most common pattern is that the hag represents the barren land, who the hero of the tale must approach without fear, and come to love on her own terms. When the hero displays this courage, love, and acceptance of her hideous side, the sovereignty hag then reveals that she is also a young and beautiful goddess.