"And Leah said, God has endowed me with a good endowment; now my husband will dwell with me" (Genesis 30:20). This field, as long as you fertilize it and hoe it, it produces. "And afterward she bore a daughter" (Genesis 30:21). There we have learned: if a man's wife is pregnant and he says, "May it be Your will that my wife bear a male," this is a vain prayer. Rabbi Yannai said: this applies when she is sitting on the birthstool. This teaching - Rabbi Yehudah ben Pazi said: even when she is sitting on the birthstool the child can still change, as it is written, "Can I not do with you, house of Israel, as this potter? Behold, like clay in the hand of the potter" (Jeremiah 18:6). They objected: but is it not written, "And afterward she bore a daughter"? He said to him: the essence of Dinah's creation was originally male, and through the prayer of Rachel, who said, "May the LORD add to me another son" (Genesis 30:24), it became female. The matriarchs were prophetesses. It does not say "other sons" but "another son." Rachel said: one more son is destined to arise; would that he come from me. All the matriarchs gathered and said: enough males among us; let this one too be remembered favorably for Rachel. And does prayer not avail? But it is written, "And afterward she bore a daughter." What is "afterward"? After Leah judged the matter within herself. She said before Him: Master of the universe, twelve tribes are destined to come from Jacob; six have come from me and four from the handmaids. If this one is male, my sister will not be even like one of the handmaids. Immediately the male was turned into a female, as it is said, "And she called her name Dinah." One resolves this: miraculous deeds are not invoked as proof. And if you prefer, say: Leah's act was within the first forty days. As it is taught: in the first three days a man should pray that the seed not spoil; from three to forty days he should pray that it be male; from forty days to three months he should pray that it not be malformed; from three to six months that it not be a stillbirth; from six to nine months that it come forth in peace. And does prayer avail? Did not Rabbi Yitzchak say: what is written, "If a woman conceives and bears a male" (Leviticus 12:2) - if the woman emits seed first she bears a male, if the man emits first she bears a female? Here we deal with a case where both emitted together.
Leah's Prayer That Turned a Son Into Dinah
Yalkut Shimoni on Torah 130:1
(בראשית ל כ) וַתֹּאמֶר לֵאָה זְבָדַנִי אֱלֹהִים אֹתִי זֵבֶד טוֹב הַפַּעַם יִזְבְּלֵנִי אִישִׁי. הַשָׂדֶה הַזּוּ כָּל זְמַן שֶׁאַתָּה מְזַבְּלָהּ וּמְעַדְּרָהּ הִיא עוֹשָׂה. (בראשית ל כא) וְאַחַר יָלְדָה בַּת. תַּמָּן תָּנִינָן הֲרֵי שֶׁהָיְתָה אִשְׁתּוֹ מְעֻבֶּרֶת וְאָמַר יְהִי רָצוֹן שֶׁתֵּלֵד אִשְׁתִּי זָכָר, הֲרֵי זוֹ תְּפִלַּת שָׁוְא רַבִּי יַנָּאי אוֹמֵר, בְּיוֹשֶׁבֶת עַל הַמַּשְׁבֵּר הֲדָא מַתְנִיתָא רַבִּי יְהוּדָה בֶּן פַּזִי אָמַר, אַף בַּיּוֹשֶׁבֶת עַל הַמַּשְׁבֵּר יָכוֹל הוּא לְהִשְׁתַּנּוֹת. הֲדָא הוּא דִּכְתִיב (ירמיה יח, ו) "הֲכַיּוֹצֵר הַזֶּה לֹא אוּכַל לַעֲשׂוֹת לָכֶם בֵּית יִשְׂרָאֵל... הִנֵּה כַחֹמֶר בְּיַד הַיּוֹצֵר" וְגוֹ' הֵתִיבוּן וְהַכְּתִיב וְאַחַר יָלְדָה בַּת, אָמַר לֵיהּ עִיקָר בְּרִיָּתָהּ שֶׁל דִּינָה זָכָר הָיְתָה וּמִתְּפִלָּתָה שֶׁל רָחֵל, שֶׁאָמְרָה "יֹסֵף ה' לִי בֵּן אַחֵר", נַעֲשָׂה נְקֵבָה הָאִמָהוֹת נְבִיאוֹת הָיוּ יוֹסֵף ה' לִי בָּנִים, אֲחֵרִים לֹא נֶאֱמַר אֶלָּא "בֵּן אַחֵר", אָמְרָה עוֹד אֶחָד הוּא עָתִיד לַעֲמוֹד, וְהַלְוַאי יִהְיֶה מִמֶּנִּי. נִתְכַּנְּסוּ כָּל הָאִמָּהוֹת וְאָמְרוּ דַּיֵּנוּ זְכָרִים, תִּפָּקֵד עוֹד זֹאת בְּרָחֵל. הָיְתָה אִשְׁתּוֹ מְעֻבֶּרֶת וְאָמַר יְהִי רָצוֹן שֶׁתֵּלֵד אִשְׁתִּי זָכָר, הֲרֵי זֶה תְּפִלַּת שָׁוְא. וְלָא מְהֲנֵי רַחֲמֵי, וְהַכְּתִיב וְאַחַר יָלְדָה בַּת, מַאי וְאַחַר אַחַר שֶׁדָּנָה לֵאָה דִּין בְּעַצְמָהּ, אָמְרָה לְפָנָיו, רִבּוֹנוֹ שֶׁל עוֹלָם שְׁנֵים עָשָׂר שְׁבָטִים עֲתִידִין לָצֵאת מִיַּעֲקֹב, שִׁשָּׁה יָצְאוּ מִמֶּנִּי, וְאַרְבָּעָה מִן הַשְּׁפָחוֹת, אִם זֶה זָכָר הוּא, לֹא תְּהֵא אֲחוֹתִי כְּאַחַת מִן הַשְּׁפָחוֹת. מִיַּד נֶהְפַּךְ זָכָר לִנְקֵבָה, שֶׁנֶּאֱמַר וַתִּקְרָא אֶת שְׁמָהּ דִּינָה, וּמְתָרֵץ אֵין מַזְכִּירִין מַעֲשֵׂה נִסִּים, וְאִיבָּעִית אֵימָא, מַעֲשֶׂה דְלֵאָה בְּתוֹךְ אַרְבָּעִים הֲוָה, כִּדְתַנְיָא, שְׁלשָׁה יָמִים הָרִאשׁוֹנִים יְבַקֵּשׁ אָדָם רַחֲמִים שֶׁלֹּא יַסְרִיחַ מִשְּׁלֹשָׁה וְעַד אַרְבָּעִים יְבַקֵּשׁ רַחֲמִים שֶׁיְּהֵא זָכָר, מֵאַרְבָּעִים וְעַד שְׁלֹשָׁה חֳדָשִׁים יְבַקֵּשׁ רַחֲמִים דְּלָא יְהֵא סַנְדָּל, מִשְּׂלֹשָׁה חֳדָשִׁים וְעַד שִׁשָׁה חֳדָשִׁים יְבַקֵּשׁ רַחֲמִים שֶׁלֹּא יְהֵא נֵפֶל, מִשִׁשָׁה חֳדָשִׁים עַד תִּשְׁעָה חֳדָשִׁים יְבַקֵּשׁ רַחֲמִים שֶׁיֵּצֵא מֵאִמּוֹ בְּשָׁלוֹם. וּמִי מְהֲנֵי רַחֲמֵי וְהָא אָמַר רַבִּי יִצְחָק, מַאי דִּכְתִיב (ויקרא יב, ב) "אִשָּׁה כִּי תַזְרִיעַ וְיָלְדָה זָכָר", אִשָּׁה מַזְרַעַת תְּחִלָּה יוֹלֶדֶת זָכָר אִישׁ מַזְרִיעַ תְּחִלָּה יוֹלֶדֶת נְקֵבָה, הָכָא בְּמַאי עַסְקִינָן שֶׁהִזְרִיעוּ שְׁנֵיהֶם כְּאֶחָד.