In terms of ghosts and demons, the origin of so called ghosts and demons are the appearances or conceptual thoughts. Conceptual thoughts originate from literally clinging to an ‘I’; clinging to this idea of ‘I’ being the centre of everything. The tangible and intangible demons originate because of one’s conceptual thoughts. These are all kinds of delusions. In a way, it is easy to say ‘Do not have conceptual thoughts. These are demons, period.’ That would be very, very easy to say, but when it comes to practice, one has to do it step by step.
To use a good example as to how to reduce or eliminate these things, the best example probably would be the steps taken by Milarepa. Follow each and every story and try to learn between the lines and as well as the deeper and more profound meanings that each story carries. Milarepa says that - of all the powerful demons, conceptual thoughts, to me is the most destructive. It is also said when you have the own Buddha nature, it is clean, it is pristine, it is spotless it is just like a mirror. When that is tainted the out of this taintedness arise all kinds of different demons. Even if you are a deity if your mirror is clouded, if your mirror is tainted you are no longer a deity. Then it is all about when our state of mind being the mirror is tainted or not.