From Kathryn Walton at Medievalists.net:
People have always been fascinated by ghosts. Tales of humans returned from the dead have appeared in folklore and literature from around the world for millennia. The medieval period was no different. Tales of actual hauntings were common in medieval folklore. Many people believed in the ability of ghosts to return and haunt individuals, places, or communities. The feature “The Ghosts of Byland Abbey” gives a great example of one haunting piece of folklore from the period.
But ghosts were also common in medieval literature, and ghost beliefs that circulated at the time shaped how they were depicted.
Belief in ghosts was not actually common across the Middle Ages. While the early people who inhabited Britain probably had some belief in ghosts, when Christianity arrived in the country, the new religion made some attempt to stamp out this superstition. Saint Augustine had denied that there could be any relations between the living and the dead; he’d insisted that apparitions of ghosts were demonic illusions. Later Christian thinkers echoed his ideas and attempted to deny that ghosts actually roamed the earth.
According to Jean-Claude Schmitt (whose book Ghosts in the Middle Ages gives a great overview of the history of medieval ghost belief) early Christian thinkers took this approach to prevent the worship of the dead, which was considered an inherently pagan practice. They also wanted to redirect attention towards the importance of the soul in heaven.
Belief in ghosts, however, lived on and was eventually accepted into Christian thinking. Gregory the Great composed a few small stories about dead people who spoke to the living to request their prayers. This idea appealed to later Christian thinkers and eventually ghosts began to appear in medieval ecclesiastical literature. Ghosts were understood then as souls stuck in purgatory who would appear to their relatives and others with warnings and requests for prayers.
This belief soon made its way into the literary world and some really fantastic ghoulish characters began to appear in medieval literature. There are too many to discuss in a single feature, but a few of the most interesting appear in the most famous literary tradition to survive from medieval England and France: the legends of King Arthur.
More at the link.