Heian/Medieval Japanese Understanding of Ghosts
Tama (life force in  individual 
living beings)
Ujigami (communal life force, clan deity; combination of kami and tama/shiryô) 
e.g. Amaterasu (ancestor deity of Yamato clan)
Kami (awe-inspiring sacred power in natural objects & phenomena) 
e.g. waterfall, thunder
   
Subcategories of Tama: Subcategory of Kami:
Ikiryô (tama that leaves a living body and possesses others) 
e.g. Rokujô
Shiryô (tama that hangs around on earth after death)
 
Ekijin (illness/epidemic kami)
 
Other Heian Terms:  
Mononoke (general term for possessing tama, often female; can be living/ikiryô or dead/shiryô) 
e.g. Rokujô
Onryô, Goryô (vengeful, angry shiryô, usually male; rather than cause possession illness, causes natural disasters; sometimes merged with ekijin; if very powerful may be pacified/deified as beneficent kami) 
e.g. Sugawara no Michizane
 
Heian/Medieval Buddhist Terms:
Muenbotoke (tama with no "link" [en] to the living; needs rituals to achieve peace/ enlightenment) Hungry Ghosts/Gaki (tama understood to be reincarnated as gaki because of desire for worldly pleasures such as food, money, sex etc.) Jôbutsu (after death, with proper rituals the tama becomes a Buddha)