“Master,” said John, “we saw someone driving out demons in your name and we tried to stop him, because he is not one of us.”
“Do not stop him,” Jesus said, “for whoever is not against you is for you.”

–Parallel verses:
Acts 19:14-17
“Some Jews who went around driving out evil spirits tried to invoke the name of the Lord Jesus over those who were demon-possessed. They would say, ‘In the name of the Jesus whom Paul preaches, I command you to come out.’ Seven sons of Sceva, a Jewish chief priest, were doing this. One day the evil spirit answered them, ‘Jesus I know, and Paul I know about, but who are you?’ Then the man who had the evil spirit jumped on them and overpowered them all. He gave them such a beating that they ran out of the house naked and bleeding. When this became known to the Jews and Greeks living in Ephesus, they were all seized with fear, and the name of the Lord Jesus was held in high honor.”

The Luke 9 passage above can be confusing as we look at Biblical context later on in Acts in the parallel verses. So on the one hand, Jesus said not to stop people if they are casting out evil spirits in his name. Whoever is not your enemy is your friend. Then, in Acts, we find these men are attacked for trying to do this.

Is this a contradiction in the Bible?

I think in this case, Jesus might have been trying to prove a point to the disciples: that they did not have the market cornered on using the power of God through Jesus. And not to make a big deal or get distracted from their work because someone else was doing something good without going through the proper channels.

In the Acts passage, it is clear these people either did not have their faith in God built up or had allowed impure motives to grow in their hearts. This is because they were brutally attacked by the demon. Notice what the demon says: “Jesus I know, and Paul I know about, but who are you?” In saying this, the demon identifies that these men were operating solo on this mission; they were not operating in the will and power of Jesus. If they were, the demon would have been forced to recognize the power of Jesus flowing through them and his power to overcome evil. And the inference in the text here is that the community had become flippant with the use of Jesus’ name. This is inferred when it says, “they were all seized with fear and the name of the Lord Jesus was held in high regard.” Evidently this was not the case beforehand.

So the takeaways today are twofold: 1) Don’t worry about what others are doing if it is not contrary to the gospel. Focus on your own faith-building, your own calling from the Lord, and your own work of the ministry. 2) Don’t get flippant with the name of Jesus. He is not a buddy or pal or a swear word. He is Lord of All. And he demands and expects our respect. If we pretend to be his servants, but have impure motives, we will fall into the judgment of God. It seems clear that God may have allowed these men to be beaten to prove a point and help resurrect a healthy Awe of Jesus Christ as Lord.

Lord, thank you for all the ways you love us. Thank you for these instructions on how to deal with those who do your work and how to leave judgment to you. And thank you for the warning to revere your name. May I be a faithful and reverent servant! May I stay closely connected to your will and operate in your power today.