Can A House Stand Divided Or Not?

If Jesus teaches that a house divided against itself cannot stand, how can the non-believers mention Matthew 17:22 perform miracles and cast out demons?

And Jesus knew their thoughts, and said unto them, Every kingdom divided against itself is brought to desolation, and every city or house divided against itself shall not stand: And if Satan cast out Satan, he is divided against himself; how shall then his kingdom stand? (Matthew 12:25-26)

Does this passage offer a contradiction against Matthew 17:22, where it seems non-believers can cast out Satan and his demons?

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 17:22-23)

When it comes to oddities like this the way to shed light on it is to adhere to the verse/passage/doctrine that is clearest and which leaves no room for ambiguity. In this example that would be our passage in Matthew 12. Our passage in Matthew 17, isolated from its proper context, leaves some things unanswered as Jesus does not affirm to His audience that these miracles/exorcisms were legitimate.

In Matthew 12 Jesus is teaching a doctrine in refutation of an accusation thrown at Him by the Pharisees that He was the prince of the devils. On the other hand, in Matthew 17 Jesus is telling His followers to watch out for false teachers and prophets. In this light, verses 22-23 serve as a prediction of their deceiver’s response to being found out (either by the disciples or by being exposed before the judgement seat (2 Corinthians 5:9-11)) and not as an admission that unbelievers can cast out demons. We have every reason to believe these people will use the name of Jesus for their own dishonest gain and is probable that they will never even believe in the things they claim to do.

Not much has changed from the first century to today. False teachers, who claim to be able to perform signs and wonders, perhaps even exorcisms, are as alive today as they were in Jesus’ time. But signs and wonders does not a follower make. When they come face to face with the justice and the glory of God, how would they respond?