Jesus made two statements that seem to contradict each other:
He that is not with me is against me: and he that gathereth not with me scattereth. [Luke 11:23]
For he that is not against us is on our part. [Mark 9:40]
While these are not mutually exclusive statements [they can both be true], they do give us pause at first glance, as they are confusing when viewed in isolation, rather than in context.
Here’s the context of Luke 11:23:
But he, knowing their thoughts, said unto them, Every kingdom divided against itself is brought to desolation; and a house divided against a house falleth. If Satan also be divided against himself, how shall his kingdom stand? because ye say that I cast out devils through Beelzebub. And if I by Beelzebub cast out devils, by whom do your sons cast them out? therefore shall they be your judges. But if I with the finger of God cast out devils, no doubt the kingdom of God is come upon you. When a strong man armed keepeth his palace, his goods are in peace: But when a stronger than he shall come upon him, and overcome him, he taketh from him all his armour wherein he trusted, and divideth his spoils. He that is not with me is against me: and he that gathereth not with me scattereth.
Jesus is talking about two things:
The work and power of His kingdom and His supremacy over Satan.
The nature of this work, which is to gather and save, not to condemn.
Those who actively oppose the Christ are enemies of the gospel. Therefore, they will also oppose us (John 15:20). There are two groups on earth, as evidenced by the broad counsel of scripture:
Children of this world versus children of light (Luke 16:8)
Children of disobedience and wrath vs. children of obedience (Ephesians 2:1-3)
Tares versus wheat (Matthew 13:30)
A corrupt tree versus a good tree (Matthew 7:15-20)
Goats versus sheep (Matthew 25:33)
The converted, indwelled by the Holy Spirit, have the power to discern between good and evil. This pertains to every situation: everything [every thought, word, and action] is inspired either by self, Satan, or Christ. [Self-love is the antithesis of the gospel.]
The works of God and Satan are eternally opposed and incompatible, as works of a distinctly different nature, bearing distinctly different fruits (Galatians 5). [Consequently, blasphemy is attributing Satan’s works to God or God’s works to Satan.]
Christ came to forcibly dispossess the enemy of those whom Satan holds captive, against their will [seeking and saving that which is lost].
Here’s the context of Mark 9:40:
And John answered him, saying, Master, we saw one casting out devils in thy name, and he followeth not us: and we forbad him, because he followeth not us. But Jesus said, Forbid him not: for there is no man which shall do a miracle in my name, that can lightly speak evil of me. For he that is not against us is on our part.
Here, the Lord makes a practical point: those who do not actively oppose His work and kingdom–yet they know Him not–are not to be considered enemies of the gospel. These will be converted and/or judged in time, as those who will either eventually bear fruits worthy of repentance or be revealed as tares among the wheat (Matthew 3:7-8; 13:30).
A few concluding thoughts:
It is possible to do miracles in the Name of Christ, yet not know him. As hard as it is for us to understand this, it agrees with other portions of scripture, and therefore, we must accept its plain rendering. “Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works? And then will I profess unto them, I never knew you: depart from me, ye that work iniquity,” (Matthew 7:22-23). For example, the Lord used both Balaam [a sorcerer] and Caiaphas [a sadducee who conspired against Christ] to prophesy (Numbers 22-23; John 11:49-52).
We see an example of how God responds to people according to their hearts in His dealings with the Canaanites [also known as the Amalekites and the Amorites]: when they actively opposed God [which is most of their history], He utterly destroyed them (Joshua 10:10; 11:8); and yet, when they chose to deal peaceably with the people of God, they found rest in the land (1 Samuel 7:14).