Certainly one invites possession when one initiates contact with demons.
This could be through physical objects such as ouija boards, which are thought to have supernatural powers (a form of idolatry in violation of the second commandment), or through direct appeal (in violation of the first commandment).
Using a medium, King Saul tried to make contact with spirits other than God:
Then Saul said to his servants, “Find me a woman who is a medium, that I may go to her and inquire of her.” And his servants said to him, “In fact, there is a woman who is a medium at En Dor.”
…
And he said, “Please conduct a seance for me, and bring up for me the one I shall name to you.”
…
And the king said to her, “Do not be afraid. What did you see?” And the woman said to Saul, “I saw a spirit ascending out of the earth.”
— 1 Samuel 28:7–13
We know this spirit couldn't have actually been Samuel, who was buried and unconsciously awaiting resurrection (e.g. Ecclesiastes 9:5 "the dead know nothing").
Whether a demon possessed Saul at this point, or whether he was already possessed, we don't know, but he went downhill after this, eventually killing himself.
In Acts 16:16, we are told of a "slave girl possessed with a spirit of divination … who brought her masters much profit by fortune-telling", again illustrating the link between the spirit world and possession.
But when it comes to inviting Satan into our lives, such deliberate contact isn't required.
There is a far more common cause.
Paul describes how Satan can make use of us, when our hatreds, resentments, etc. leave us open to his influence:
… on the contrary, you ought rather to forgive and comfort him, lest perhaps such a one be swallowed up with too much sorrow.
Therefore I urge you to reaffirm your love to him.
For to this end I also wrote, that I might put you to the test, whether you are obedient in all things.
Now whom you forgive anything, I also forgive. For if indeed I have forgiven anything, I have forgiven that one for your sakes in the presence of Christ,
lest Satan should take advantage of us; for we are not ignorant of his devices.
— 2 Corinthians 2:7–11
Again, Paul warns about the importance of forgiveness, and how failure to forgive creates a place for the devil:
Therefore, putting away lying, “Let each one of you speak truth with his neighbor,” for we are members of one another.
“Be angry, and do not sin”: do not let the sun go down on your wrath,
nor give place to the devil.
…
Let all bitterness, wrath, anger, clamor, and evil speaking be put away from you, with all malice.
And be kind to one another, tenderhearted, forgiving one another, even as God in Christ forgave you.
— Ephesians 4:25–32
Forgiveness is perhaps the single-most important aspect of Christianity.
It is how God shows love, and it is how Christians show their love.
Jesus presented a model prayer, which praises God and asks for certain things.
But it contains only one promise that the person praying offers: "forgive us our debts, as we forgive our debtors".
Jesus then goes on to emphasize the importance of forgiveness:
For if you forgive men their trespasses, your heavenly Father will also forgive you.
But if you do not forgive men their trespasses, neither will your Father forgive your trespasses.
— Mark 6:14–15
Failing to forgive puts a terrible burden on one's mind, and that creates an open invitation for possession.
Even the secular world, which denies demon spirits, recognizes that long-time hatreds and grudges can seriously affect mental well-being, and literally refers to such afflictions as demons.
Whether one is a Christian or not, forgiving and ridding oneself of festering negative thoughts is perhaps the best thing one can do for oneself.