Jesus had all authority over demons. Because He is God, they must obey Him.
And they went into Capernaum; and straightway on the sabbath day he entered into the synagogue, and taught. And they were astonished at his doctrine: for he taught them as one that had authority, and not as the scribes. And there was in their synagogue a man with an unclean spirit; and he cried out,
Saying, Let us alone; what have we to do with thee, thou Jesus of Nazareth? art thou come to destroy us? I know thee who thou art, the Holy One of God. And Jesus rebuked him, saying, Hold thy peace, and come out of him. And when the unclean spirit had torn him, and cried with a loud voice, he came out of him. And they were all amazed, insomuch that they questioned among themselves, saying, What thing is this? what new doctrine is this? for with authority commandeth he even the unclean spirits, and they do obey him.