"He said to him: 'If the men have come to call you, rise up, go with them.' After the Holy One, blessed be He, had said to him once, 'You shall not go with them' — for He desired that his portion not be with them — yet he wished to go, He granted him permission, as it is said: 'If it concerns the scoffers, He scoffs at them' (Proverbs 3:34). And furthermore, so that he would not exalt himself, saying, 'If He gives me permission to go, I will do all my will, and I would only have refrained on His account' — the Holy One, blessed be He, showed him that all that He had withheld from him He did only to shame him, and made known to him that even though he goes by the permission of the Holy One, blessed be He, he stands subject to Him, and can do nothing without His permission.
God Lets Balaam Go to Shame Him Not Free Him
Midrash Aggadah, Numbers 22:20
ויאמר לו אם לקרא לך באו האנשים קום לך אתם. אחר שאמר לו הקב"ה פעם אחת לא תלך עמהם, שבקש שלא יהא חלקו עמהם, הוא חפץ ללכת נתן לו רשות, שנאמר אם ללצים הוא יליץ (משלי ג לד). ועוד שלא יתגאה בעצמו לומר אם יתן לי רשות ללכת אעשה כל רצוני, ולא הייתי מניח אלא בעבורו, והראה לו הקב"ה שכל מה שמנעו לא עשה אלא לבשתו והודיעו שאע"פ שילך ברשותו של הקב"ה הוא עומד, ולא יכול לעשות שום דבר בלא רשותו: