Rambam insists that free will is a foundational principle without which reward and punishment are meaningless. The Mei HaShiloach is in creative tension with this: he agrees free will exists but teaches that for the purified tzaddik whose desire has become identified with God's will, the question of free will dissolves.
רְשׁוּת לְכָל אָדָם נְתוּנָה. אִם רָצָה לְהַטּוֹת עַצְמוֹ לְדֶרֶךְ טוֹבָה וְלִהְיוֹת צַדִּיק הָרְשׁוּת בְּיָדוֹ. וְאִם רָצָה לְהַטּוֹת עַצְמוֹ לְדֶרֶךְ רָעָה וְלִהְיוֹת רָשָׁע הָרְשׁוּת בְּיָדוֹ. הוּא שֶׁכָּתוּב בַּתּוֹרָה (בראשית ג כב) "הֵן הָאָדָם הָיָה כְּאַחַד מִמֶּנּוּ לָדַעַת טוֹב וָרָע". כְּלוֹמַר הֵן מִין זֶה שֶׁל אָדָם הָיָה יָחִיד בָּעוֹלָם וְאֵין מִין שֵׁנִי דּוֹמֶה לוֹ בְּזֶה הָעִנְיָן שֶׁיְּהֵא הוּא מֵעַצְמוֹ בְּדַעְתּוֹ וּבְמַחֲשַׁבְתּוֹ יוֹדֵעַ הַטּוֹב וְהָרַע וְעוֹשֶׂה כָּל מַה שֶּׁהוּא חָפֵץ וְאֵין מִי שֶׁיְּעַכֵּב בְּיָדוֹ מִלַּעֲשׂוֹת הַטּוֹב אוֹ הָרַע. וְכֵיוָן שֶׁכֵּן הוּא פֶּן יִשְׁלַח יָדוֹ: אַל יַעֲבֹר בְּמַחֲשַׁבְתְּךָ דָּבָר זֶה שֶׁאוֹמְרִים טִפְּשֵׁי אֻמּוֹת הָעוֹלָם וְרֹב גָּלְמֵי בְּנֵי יִשְׂרָאֵל שֶׁהַקָּדוֹשׁ בָּרוּךְ הוּא גּוֹזֵר עַל הָאָדָם מִתְּחִלַּת בְּרִיָּתוֹ לִהְיוֹת צַדִּיק אוֹ רָשָׁע. אֵין הַדָּבָר כֵּן אֶלָּא כָּל אָדָם רָאוּי לוֹ לִהְיוֹת צַדִּיק כְּמשֶׁה רַבֵּנוּ אוֹ רָשָׁע כְּיָרָבְעָם אוֹ חָכָם אוֹ סָכָל אוֹ רַחֲמָן אוֹ אַכְזָרִי אוֹ כִּילַי אוֹ שׁוּעַ וְכֵן שְׁאָר כָּל הַדֵּעוֹת. וְאֵין לוֹ מִי שֶׁיִּכְפֵּהוּ וְלֹא גּוֹזֵר עָלָיו וְלֹא מִי שֶׁמּוֹשְׁכוֹ לְאֶחָד מִשְּׁנֵי הַדְּרָכִים אֶלָּא הוּא מֵעַצְמוֹ וּמִדַּעְתּוֹ נוֹטֶה לְאֵי זוֹ דֶּרֶךְ שֶׁיִּרְצֶה. הוּא שֶׁיִּרְמְיָהוּ אָמַר (איכה ג לח) "מִפִּי עֶלְיוֹן לֹא תֵצֵא הָרָעוֹת וְהַטּוֹב". כְּלוֹמַר אֵין הַבּוֹרֵא גּוֹזֵר עַל הָאָדָם לִהְיוֹת טוֹב וְלֹא לִהְיוֹת רַע. וְכֵיוָן שֶׁכֵּן הוּא נִמְצָא זֶה הַחוֹטֵא הוּא הִפְסִיד אֶת עַצְמוֹ. וּלְפִיכָךְ רָאוּי לוֹ לִבְכּוֹת וּלְקוֹנֵן עַל חֲטָאָיו וְעַל מַה שֶּׁעָשָׂה לְנַפְשׁוֹ וּגְמָלָהּ רָעָה. הוּא שֶׁכָּתוּב אַחֲרָיו (איכה ג לט) "מַה יִּתְאוֹנֵן אָדָם חָי" וְגוֹ'. וְחָזַר וְאָמַר הוֹאִיל וּרְשׁוּתֵנוּ בְּיָדֵינוּ וּמִדַּעְתֵּנוּ עָשִׂינוּ כָּל הָרָעוֹת רָאוּי לָנוּ לַחֲזֹר בִּתְשׁוּבָה וְלַעֲזֹב רִשְׁעֵנוּ שֶׁהָרְשׁוּת עַתָּה בְּיָדֵינוּ. הוּא שֶׁכָּתוּב אַחֲרָיו (איכה ג מ) "נַחְפְּשָׂה דְרָכֵינוּ וְנַחְקֹרָה וְנָשׁוּבָה" וְגוֹ': וְדָבָר זֶה עִקָּר גָּדוֹל הוּא וְהוּא עַמּוּד הַתּוֹרָה וְהַמִּצְוָה שֶׁנֶּאֱמַר (דברים ל טו) "רְאֵה נָתַתִּי לְפָנֶיךָ הַיּוֹם אֶת הַחַיִּים". וּכְתִיב (דברים יא כו) "רְאֵה אָנֹכִי נֹתֵן לִפְנֵיכֶם הַיּוֹם". כְּלוֹמַר שֶׁהָרְשׁוּת בְּיֶדְכֶם. וְכָל שֶׁיַּחְפֹּץ הָאָדָם לַעֲשׂוֹת מִמַּעֲשֵׂה בְּנֵי הָאָדָם עוֹשֶׂה בֵּין טוֹבִים בֵּין רָעִים. וּמִפְּנֵי זֶה הָעִנְיָן נֶאֱמַר (דברים ה כו) "מִי יִתֵּן וְהָיָה לְבָבָם זֶה לָהֶם". כְּלוֹמַר שֶׁאֵין הַבּוֹרֵא כּוֹפֶה בְּנֵי הָאָדָם וְלֹא גּוֹזֵר עֲלֵיהֶן לַעֲשׂוֹת טוֹבָה אוֹ רָעָה אֶלָּא הַכּל מָסוּר לָהֶם:
Free will is granted to all men. If one desires to turn himself to the path of good and be righteous, the choice is his. Should he desire to turn to the path of evil and be wicked, the choice is his. This is [the intent of] the Torah's statement (Genesis 3:22 : "Behold, man has become unique as ourselves, knowing good and evil," i.e., the human species became singular in the world with no other species resembling it in the following quality: that man can, on his own initiative, with his knowledge and thought, know good and evil, and do what he desires. There is no one who can prevent him from doing good or bad. Accordingly, [there was a need to drive him from the Garden of Eden,] "lest he stretch out his hand [and take from the tree of life]." A person should not entertain the thesis held by the fools among the gentiles and the majority of the undeveloped among Israel that, at the time of a man's creation, The Holy One, blessed be He, decrees whether he will be righteous or wicked. This is untrue. Each person is fit to be righteous like Moses, our teacher, or wicked, like Jeroboam. [Similarly,] he may be wise or foolish, merciful or cruel, miserly or generous, or [acquire] any other character traits. There is no one who compels him, sentences him, or leads him towards either of these two paths. Rather, he, on his own initiative and decision, tends to the path he chooses. This was [implied by the prophet,] Jeremiah who stated [Eichah 3:38: "From the mouth of the Most High, neither evil or good come forth." The Creator does not decree that a person should be good and refrain from being evil. Accordingly, it is the sinner, himself, who causes his own loss. Therefore, it is proper for a person to cry and mourn for his sins and for what he has done to his soul, the evil consequences, he brought upon it. This is implied by the following verse [ibid.:39]: "Of what should a living man be aggrieved? [A man of his sins.]" [The prophet] continues explaining, since free choice is in our hands and our own decision [is what prompts us to] commit all these wrongs, it is proper for us to repent and abandon our wickedness, for this choice is presently in our hand. This is implied by the following verse [ibid.:40]: "Let us search and examine our ways and return [to God]." This principle is a fundamental concept and a pillar [on which rests the totality] of the Torah and mitzvot as [Deuteronomy 30:15] states: "Behold, I have set before you today life [and good, death and evil]." Similarly, [Deuteronomy 11:26] states, "Behold, I have set before you today [the blessing and the curse]," implying that the choice is in your hands. Any one of the deeds of men which a person desires to do, he may, whether good or evil. Therefore, [Deuteronomy 5:26] states: "If only their hearts would always remain this way." From this, we can infer that the Creator does not compel or decree that people should do either good or bad. Rather, everything is left to their [own choice].