In reading Mark 9:39, it seems as though the Lord teaches that those who cast out demons in his name are to be treated as believers, and yet in Luke 11:18, Mark 3:26, and Matthew 12:26, Jesus says that there will be those who cast out demons in His name but He does not know them. Can you help me understand this difference?
Regarding each of the passages you cited, here are some general observations. First, Luke 9:49-50 & Mark 9:39 are both speaking of those who are working by means of the Spirit of God though not publicly identified as disciples following Jesus. These men were successfully casting out demons “in Jesus name,” which means they were operating in the power and authority of the Lord, which had been granted to them by the Spirit.
The disciples objected to these men working in this way, because these other men were not a part of the group following Jesus, but Jesus rejects their assumptions. The Lord says God is capable of working through others who were unknown to the disciples, therefore they must not judge others merely by human associations. If a person works in like manner for a shared outcome to the glory of Christ, then we can assume they are working by the same Spirit as us.
Regarding Luke 11:18, Mark 3:26, and Matthew 12:26, Jesus said that Satan will never work against his own purposes. Jesus spoke these words because the Pharisees had accused Jesus of performing a miracle of casting out a demon using the power of Satan. Jesus explained that it would be illogical to expect Satan to lend his power to anyone for the purpose of increasing the Lord's glory.
On the other hand, Jesus was NOT declaring that Satan never grants a person the power to send out a demon. On the contrary, Satan is the ruler of the demons, and therefore he can send demons into our out of an unbeliever’s body at will. Satan may grant the power to one of his agents to cast out demons from another of his agents in order to gain attention and loyalty from an audience for his evil agenda. False teachers and false prophets have long demonstrated supernatural power granted by Satan, including the power to control the demonic realm. The enemy uses this deception to win an audience for his claims.
But as Jesus said, the enemy will never use his power to further the glory or goals of the Lord, which was the point Jesus was making to the Pharisees. Therefore, we cannot say that those who cast out demons must be believers, because sometimes unbelievers cast out demons to further the purposes of Satan. We can only say that those who bring glory to Jesus in their work to further the kingdom are not our enemies.
This truth explains why in Matthew 7:22 Jesus declares that some will prophesy and cast out demons in Jesus’ name yet He will say He doesn’t know them at the judgment. These are unbelievers who were under the influence of false teaching and were working in the power of Satan to accomplish great miracles, but they didn’t have the Spirit and didn’t know the true Gospel. Present-day examples of such people include Jehovah’s Witnesses, Mormons, and unbelievers trapped in many pentecostal movements around the world.
Furthermore, there is no example in scripture of the Lord granting an unbeliever spiritual power to perform miracles, but there are many occasions of Satan granting such power to unbelievers (including the antichrist to come). Therefore, we cannot make a determination concerning someone’s spiritual status (i.e., believer vs. unbeliever) merely on the basis of whether they can perform supernatural signs. This is why the Bible warns against seeking for such signs.
Finally, the Bible is clear that the unbeliever’s prayers are not “heard” by God in the sense that the Spirit isn’t working within such a person to bring their prayers into alignment with the will of God nor does Jesus intercede on their behalf.