The law is for lawbreakers, grace is for those who believe. Also, Jesus was speaking to the crowd in His time, and this was before resurrection.bbyrd009 said:21“Not everyone who says to Me, ‘Lord, Lord! ’ will enter the kingdom of heaven, but only the one who does the will of My Father in heaven.
22On that day many will say to Me, ‘Lord, Lord, didn’t we prophesy in Your name, drive out demons in Your name, and do many miracles in Your name? ’
23Then I will announce to them, ‘I never knew you! Depart from Me, you lawbreakers!’
Rom 6:14 For sin shall no longer be your master, because you are not under the law, but under grace.
1 Tim 1:8-11 We know that the law is good if one uses it properly. 9We also know that the law is made not for the righteous but for lawbreakers and rebels, the ungodly and sinful, the unholy and irreligious, for those who kill their fathers or mothers, for murderers, 10for the sexually immoral, for those practicing homosexuality, for slave traders and liars and perjurers—and for whatever else is contrary to the sound doctrine 11that conforms to the gospel concerning the glory of the blessed God, which he entrusted to me.
Gill's Exposition of the Entire Bible
And in thy name have cast out devils? Diabolical possessions were very frequent in the times of Christ; no doubt but they were suffered, that Jesus might have an opportunity of showing his power over Satan, by dispossessing him from the bodies, as well as the souls of men; and of giving proof of his deity, divine sonship and Messiahship: and this power of casting out devils was given to others, not only to the twelve apostles, among whom Judas was, who had the same power with the rest, and to the seventy disciples; but even to some who did not follow him, and his disciples, Mark 9:38 and some did this in the name of Jesus, who do not appear to have any true faith in him, and knowledge of him; as the vagabond Jews, exorcists, and the seven sons of Sceva, Acts 19:13. An awful consideration it is, that men should be able to cast out devils, and at last be cast to the devil.
And in thy name done many wonderful works? that is, many miracles; not one, or a few only, but many; such as speaking with tongues, removing mountains, treading on serpents and scorpions, and drinking any deadly thing without hurt, and healing all manner of diseases and sicknesses. Judas, for one, was capable of pleading all these things; he had the gift of preaching, and a call from Christ to it, and yet a castaway; he had the power of casting out devils, and yet could not prevent the devil from entering into him; he could perform miracles, do wonders in Christ's name, and yet, at last, was the betrayer of him. These pleas and arguments will be of no use to him, nor of any avail to any at the great day. It may be observed, that these men lay the whole stress of their salvation upon what they have done in Christ's name; and not on Christ himself, in whom there is salvation, and in no other: they say not a syllable of what Christ has done and suffered, but only of what they have done. Indeed, the things they instance in, are the greatest done among men; the gifts they had were the most excellent, excepting the grace of God; the works they did were of an extraordinary nature; whence it follows, that there can be no salvation, nor is it to be expected from men's works: for if preaching the word, which is attended with so much study, care, and labour, will not be a prevailing argument to admit men into the kingdom of heaven; how can it be thought that ever reading, or hearing, or any other external performance of religion, should bring persons thither?