I agree with what Mawia said I added a fasting comment. I would like to add these series explanations of methods from the Bible as best I understand.
Act 10:38 How God anointed Jesus of Nazareth with the Holy Ghost and with power: who went about doing good, and healing all that were oppressed of the devil; for God was with him.
Luk 13:16 And ought not this woman, being a daughter of Abraham, whom Satan hath bound, lo, these eighteen years, be loosed from this bond on the sabbath day?
1Pe 2:24 Who his own self bare our sins in his own body on the tree, that we, being dead to sins, should live unto righteousness: by whose stripes ye were healed.
I think its important to point out that not everything we might think was a possession is a possession. All sickness whether physical or mental has its origin with the devil however most broken things in our world have their origin in the devil. For instance the fact that your and my iPad or other tablet breaks is the devils fault. We contribute to the fall of the ipad sometimes but if the devil was completely and totally removed and all his previous influences dissolved you could let go of the iPad and the spiritual forces of life in Christ Jesus would over ride the force of gravity until you grabbed it again. (John 10:10-11) Pretty kool hu?
Luk 4:18 The Spirit of the Lord is upon me, because he hath anointed me to preach the gospel to the poor; he hath sent me to heal the brokenhearted, to preach deliverance to the captives, and recovering of sight to the blind, to set at liberty them that are bruised,
So any kind of outward stealing killing or destroying which happens in your life is commonly oppression not possession. Most people agree that most oppression can be resolved with medical care. People who are sick mentally and physically are not to blame for the problems they experience as they did not originate the mental of physical sickness. Yes it is possible to give place to the devil just like its possible to give place to God but you never ever directly cause any kind of sickness. Even if you did something reckless and you want to blame yourself its not your fault you were tempted. (1Co 10:13) Had there been no temptation you are a child of God if you've made Jesus your King and Friend you would not have given in. You can repent if necessary and alter your behaviour the next time you are tempted and overcome the temptation but it is not your fault.
Mat 4:24 And his fame went throughout all Syria: and they brought unto him all sick people that were taken with divers diseases and torments, and those which were possessed with devils, and those which were lunatick, and those that had the palsy; and he healed them.
Act 16:16 And it came to pass, as we went to prayer, a certain damsel possessed with a spirit of divination met us, which brought her masters much gain by soothsaying:
Mat 8:28 And when he was come to the other side into the country of the Gergesenes, there met him two possessed with devils, coming out of the tombs, exceeding fierce, so that no man might pass by that way.
Mar 5:5 And always, night and day, he was in the mountains, and in the tombs, crying, and cutting himself with stones.
Luk 8:27 And when he went forth to land, there met him out of the city a certain man, which had devils long time, and ware no clothes, neither abode in any house, but in the tombs.
Jas 4:7 Submit yourselves therefore to God. Resist the devil, and he will flee from you.
One of the Greek word used to describe possession is echo. It is used to describe how people have things and how Marry had in her body Jesus when she was pregnant. In Mathew 4:24 the greek word sick people is a combination of echo karos. Karos means something foul or vile. The KJV translators did a good job translating this verse because sick is bad. Notice however though all the people have something bad bothering them only a subgroup of these people are actually possessed of the devil. Diverse diseases, torments, mental sickness and palsy are mentioned separate from actual demon possession. The greek word for exact demonic possession is daimonizomai "which means to be exercised by a daemon" according to strongs. Just because someone is completely insane or otherwise sick doesn't mean they are possessed by the devil. Those who are possessed by the devil may sometimes or sometimes not have other ailments. The woman possessed by a spirit of divination was somewhat normal except for occasional outburst which happen to even the sanest of people given the correct exciters or stressors. However the man of Gergesenes was obviously mentally ill in addition to being possesed by the devil. Modern psychiatry (the giving of medications like antipsychotics) could possibly have helped him return some semblance of normal like the woman from acts however it would not have removed the devils because that is not something natural but supernatural. The only time you ever absolutely ever "cast" a devil out of someone is when the Holy Spirit specifically and supernaturally reveals to you that a devil has possessed someone using the manifestation of the Holy Spirit called discerning of spirits. Discerning of spirits is rare and if it happens multiple times to you then you are probably sick and in need of medical care. It would take someone speaking the name of Jesus and or laying hands on them to remove the demon. Demons are compelled to flee at the name of Jesus (Philippians 2:10) or the ministration of God's power (James 4:7). Just because the insanity or other sickness continues progresses doesn't mean that the daemon has hasn't been cast out. Yes we do have to consistently and constantly resit the devil a few amount of times like the temptation of Christ however after the 3rd time of whatever form of Biblical resistance which you have exerted you should stop consider it done and move on. If you cannot stop or have a hard time stopping then you need help from a doctor as the devil has according to the scripture fled. If you are or the person being freed from a demon is still sick after a minimal amount of Biblically endorsed resistance it just means the person is still sick (sick isn't daimonizomai or demon possession) and needs medical attention or supernatural healing help from God. If you lay hands on a person and pray for them to be healed and for whatever reason they do not receive given a minimal amount of time go to the doctor.
That said just because medical science is unable to affect recovery in a condition does not mean that the person is possessed by the devil. Notice however that all the conditions including demonic possession have a cure in what is traditionally called casting out but instead healing. The Bible has several categories of healings the three that I am aware of are sick person initiated, God initiated and mixture of God and person initiated. The primary text for those healed by an act of God with no or little effort shown by them is:
Joh 5:3 In these lay a great multitude of impotent folk, of blind, halt, withered, waiting for the moving of the water.
Joh 5:4 For an angel went down at a certain season into the pool, and troubled the water: whosoever then first after the troubling of the water stepped in was made whole of whatsoever disease he had.
Joh 5:5 And a certain man was there, which had an infirmity thirty and eight years.
Joh 5:6 When Jesus saw him lie, and knew that he had been now a long time in that case, he saith unto him, Wilt thou be made whole?
Joh 5:7 The impotent man answered him, Sir, I have no man, when the water is troubled, to put me into the pool: but while I am coming, another steppeth down before me.
Joh 5:8 Jesus saith unto him, Rise, take up thy bed, and walk.
1Co 12:11 But all these worketh that one and the selfsame Spirit, dividing to every man severally as he will.
Mat 12:15 But when Jesus knew it, he withdrew himself from thence: and great multitudes followed him, and he healed them all;
Both the instance of the angel troubling the water and how Jesus commanded the man to be able to rise and walk are instances of the people doing little or nothing spiritually but God initiating the healing. Also the healing of malchus ear falls into the category as well as several others. These healings are sometimes and just sometimes done as a sign that God is working through a specific person like he worked through Jesus. The vast majority of healings in the New testament are this type however there is nothing an individual can do to recreate this type of manifestation individually. You can't be good enough, you can't have enough faith you can't do or say anything to force God to move in this special way. However this is not the only method to receive from God.
Mar 11:22 And Jesus answering saith unto them, Have faith in God.
Mar 11:23 For verily I say unto you, That whosoever shall say unto this mountain, Be thou removed, and be thou cast into the sea; and shall not doubt in his heart, but shall believe that those things which he saith shall come to pass; he shall have whatsoever he saith.
Mar 11:24 Therefore I say unto you, What things soever ye desire, when ye pray, believe that ye receive them, and ye shall have them.
Mar 11:25 And when ye stand praying, forgive, if ye have ought against any: that your Father also which is in heaven may forgive you your trespasses.
Mar 11:26 But if ye do not forgive, neither will your Father which is in heaven forgive your trespasses.
Jas 1:6 But let him ask in faith, nothing wavering. For he that wavereth is like a wave of the sea driven with the wind and tossed.
Mat 13:58 And he did not many mighty works there because of their unbelief.
You can pray and as Christians we believe that God answers prayers which are (I'm very sad to say) done with the right heart. It would be great if God answered every prayer but according to mark 11:23 there are certain kinds of way which you can pray which will prevent God from answering. Doubt really messes things up. Even Jesus in the flesh the standard of purity holiness and God Himself could not work with doubt and pride in Matthew 13:58 however fret not if you have doubt!
Mar 9:23 Jesus said unto him, If thou canst believe, all things are possible to him that believeth.
Mar 9:24 And straightway the father of the child cried out, and said with tears, Lord, I believe; help thou mine unbelief.
Jesus when faced with doubt with a little bit of faith and humility was able to bring about a healing and cure in the demon possessed boy from Mark 9. Notice here that the faith of a third party is sufficient for some which are incapacitated. In this method God meets you where you are and helps your faith. This is the most common way in which peopled are healed of demonic possession or healed by God.
2Co 5:17 Therefore if any man be in Christ, he is a new creature: old things are passed away; behold, all things are become new.
Rom 8:11 But if the Spirit of him that raised up Jesus from the dead dwell in you, he that raised up Christ from the dead shall also quicken your mortal bodies by his Spirit that dwelleth in you.
Rom 10:9 That if thou shalt confess with thy mouth the Lord Jesus, and shalt believe in thine heart that God hath raised him from the dead, thou shalt be saved.
Rom 10:10 For with the heart man believeth unto righteousness; and with the mouth confession is made unto salvation.
Rom 10:11 For the scripture saith, Whosoever believeth on him shall not be ashamed.
Rom 8:15 For ye have not received the spirit of bondage again to fear; but ye have received the Spirit of adoption, whereby we cry, Abba, Father.
Demonic possession because its surely spiritual always ends when a person becomes born again. The old spiritual container which was infested by demons dies and a new man in Christ indwelled by the Holy Spirit Himself is born. The sinner takes what little faith they have in God, Christ and the Holy Spirit and comes before God humbly repents and makes Jesus their King and Friend. Any doubt which plage them are made up by the power of God and a miracle is effected all demons are removed in the death of the old man and a new man is born in the complete freedom of Christ.
Even science embraces the concept of faith working miracles and even random chance miracles and the co-happening of faith with a random chance miracle. They call it the placebo and it may work for nearly anyone. Its the standard of the ability for which a drug is measured for even a sugar pill and water can outperform some drugs which do not make it to market (everyone hopes).
However having some humble faith in God is the only sure answer for salvation and the end of demonic possession.
That said if you are otherwise sick and you think you are in faith and yet you have not yet recieved the end result don't give up even just randomly believing has results. If you do give up don't blame God for God wants you to be made whole. Don't blame yourself because you're doing the absolutely best of your ability. Blame the devil and his wicked doubt and unforgiveness for hindering you.