The church grim is a spirit that guards churchyards from witches and the Devil. It usually takes the form of a black dog, although in some Scandinavian countries it may appear as a lamb, or “grave-sow”.
The first person to be buried in a new churchyard was obliged to guard it against the Devil. To avoid the need for a human soul to perform this onerous duty, a black dog would be buried in the north part of the churchyard as a substitute. According to a related Scottish belief, the spirit of the person most recently buried in a churchyard had to protect it until the next funeral provided a new guardian to replace him or her.