Both Paul's and Jesus' words are both true. The "law" spoken of in Galatians is the law of ordinances.
Let's look at this again...
But when Peter was come to Antioch, I withstood him to the face, because he was to be blamed. For before that certain came from James, he did eat with the Gentiles: but when they were come, he withdrew and separated himself, fearing them which were of the circumcision. And the other Jews dissembled likewise with him; insomuch that Barnabas also was carried away with their dissimulation. But when I saw that they walked not uprightly according to the truth of the gospel, I said unto Peter before them all, If thou, being a Jew, livest after the manner of Gentiles, and not as do the Jews, why compellest thou the Gentiles to live as do the Jews?
Gal 2:11-14
They didn't eat with the Gentiles after the "Jews" and a religious spirit entered into the scene. We're no longer commanded to be circumcised in the flesh as the law of ordinances prescribes.
O foolish Galatians, who hath bewitched you, that ye should not obey the truth, before whose eyes Jesus Christ hath been evidently set forth, crucified among you? This only would I learn of you, Received ye the Spirit by the works of the law, or by the hearing of faith? Are ye so foolish? having begun in the Spirit, are ye now made perfect by the flesh?
Gal 3:1-3
The key here is "perfected by the flesh". The works are of the flesh.
But as then he that was born after the flesh persecuted him that was born after the Spirit, even so it is now. Nevertheless what saith the scripture? Cast out the bondwoman and her son: for the son of the bondwoman shall not be heir with the son of the freewoman. So then, brethren, we are not children of the bondwoman, but of the free.
Gal 4:29-31
Even though Peter was a man of the Spirit, in this case he acted like the "bondwoman". The religious spirit objects to the walk of liberty.
Behold, I Paul say unto you, that if ye be circumcised, Christ shall profit you nothing. For I testify again to every man that is circumcised, that he is a debtor to do the whole law. Christ is become of no effect unto you, whosoever of you are justified by the law; ye are fallen from grace.
Gal 5:2-4
Circumcision according to the law. Now it is done in the heart.
For all the law is fulfilled in one word, even in this; Thou shalt love thy neighbour as thyself. But if ye bite and devour one another, take heed that ye be not consumed one of another. This I say then, Walk in the Spirit, and ye shall not fulfil the lust of the flesh. For the flesh lusteth against the Spirit, and the Spirit against the flesh: and these are contrary the one to the other: so that ye cannot do the things that ye would. But if ye be led of the Spirit, ye are not under the law.
Gal 5:14-18
Guess what? If you're not led of the Spirit, you're not fulfilling the righteous spirit of the law. You're under the law. It's right there. IF and the counter to that is you're under law, because the law was given because of transgressions. It won't pass away, not one jot or tittle until it is fulfilled.
Be not deceived; God is not mocked: for whatsoever a man soweth, that shall he also reap. For he that soweth to his flesh shall of the flesh reap corruption; but he that soweth to the Spirit shall of the Spirit reap life everlasting.
Gal 6:7-8
It's all about what you sow and reap. No getting around it.
For in Christ Jesus neither circumcision availeth any thing, nor uncircumcision, but a new creature. And as many as walk according to this rule, peace be on them, and mercy, and upon the Israel of God.
Gal 6:15-16
Back to this scripture..
Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven. 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. Therefore whosoever heareth these sayings of mine, and doeth them, I will liken him unto a wise man, which built his house upon a rock: And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell not: for it was founded upon a rock. And every one that heareth these sayings of mine, and doeth them not, shall be likened unto a foolish man, which built his house upon the sand: And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell: and great was the fall of it.
Matt 7:21-27
If you're not doing the will of God, you're working iniquity. If you're not walking in the Spirit (doing the will of God), you're under law, because you're working iniquity. If you're not doing the sayings of Jesus, you're not doing the will of the Father, because they are His commands. Great will be the fall of your house if you don't repent.
If you're walking in the Spirit, you're not under law. If you're doing the sayings of Jesus, you're house will stand. We're not redeemed from walking in love. It's what we do to enter into life. We can only "do" it because of the working of grace, by His Spirit.
Flesh - corruption
Spirit - life everlasting --- It's your choice.