Samuel said: The evil inclination is like a grain of wheat that crouches upon the entryways of the heart, as it is said, "Sin crouches at the door." While the child is still in its mother's womb, they teach it the whole Torah entirely, as it is said, (Proverbs 4:4) "And he taught me and said to me, let your heart hold fast my words." And once it comes out into the air of the world, an angel comes and strikes it upon its mouth and makes it forget the whole Torah, as it is said, "Sin crouches at the door." Antoninus said to Rabbi: From when is the evil inclination placed within a person, from the moment of emergence or from the moment of formation? He said to him: From the moment of formation. He said to him: If so, it would kick within its mother's womb and come out; rather, it is from the moment of emergence. Rabbi said: This thing Antoninus taught me, and Scripture supports him, as it is said, "Sin crouches at the door." Antoninus said to Rabbi: From when is the soul given to a person, from the moment of formation or from the moment of visitation? He said to him: From the moment of formation. He said to him: Is it possible for a piece of meat to keep three days without salt and not rot? Rather, from the moment of visitation. Rabbi said: This thing Antoninus taught me, and Scripture supports him, as it is said, "You have granted me life and steadfast love, and Your visitation has guarded my spirit."
The Evil Inclination at the Doors of the Heart and When the Soul Enters
Yalkut Shimoni on Torah 38:1
אָמַר שְׁמוּאֵל, יֵצֶר הָרָע כְּמִין חִטָּה הוּא רוֹבֵץ עַל מַפְתְּחֵי הַלֵּב, שֶׁנֶּאֱמַר לַפֶּתַח חַטָּאת רֹבֵץ. עַד שֶׁהַוָּלָד בִּמְעֵי אִמּוֹ מְלַמְּדִין אוֹתוֹ כָּל הַתּוֹרָה כֻּלָּהּ, שֶׁנֶּאֱמַר (משלי ד, ד) "וַיֹרֵנִי וַיֹּאמֶר לִי יִתְמָךְ דְּבָרַי לִבֶּךָ" וְגוֹ'. וְכֵיוָן שֶׁיָּצָא לַאֲוִיר הָעוֹלָם, בָּא מַלְאָךְ וּסְטָרוֹ עַל פִּיו וּמְשַׁכֵּחַ כָּל הַתּוֹרָה, שֶׁנֶּאֱמַר לַפֶּתַח חַטָּאת רֹבֵץ. אָמַר לֵיהּ אַנְטוּנִינוּס לְרַבִּי, מֵאֵימָתַי יֵצֶר הָרָע נָתוּן בָּאָדָם, מִשְּׁעַת יְצִיאָה אוֹ מִשְּׁעַת יְצִירָה. אָמַר לֵיהּ מִשְּׁעַת יְצִירָה. אָמַר לֵיהּ, אִם כֵּן בֹּעֵט בִּמְעֵי אִמּוֹ וְיֹצֵא, אֶלָּא מִשְּׁעַת יְצִיאָה. אָמַר רַבִּי, דָּבָר זֶה לִמְּדַנִי אַנְטוּנִינוּס וּמִקְרָא מְסַיְּעוֹ, שֶׁנֶּאֱמַר לַפֶּתַח חַטָּאת רֹבֵץ. אָמַר לֵיהּ אַנְטוּנִינוּס לְרַבִּי, נְשָׁמָה מֵאֵימָתַי נִתְּנָה בָּאָדָם מִשְּׁעַת יְצִירָה אוֹ מִשְּׁעַת פְּקִדָה אָמַר לֵיהּ מִשְּׁעַת יְצִירָה. אָמַר לֵיהּ, אֶפְשָׁר לַחֲתִיכָה שֶׁל בָּשָׂר שֶׁתִּתְקַיֵּם בְּלֹא מֶלַח שְׁלֹשָׁה יָמִים וְאֵינָהּ מַסְרַחַת אֶלָּא מִשְּׁעַת פְּקִדָה. אָמַר רַבִּי, דָּבָר זֶה לִמְּדַנִי אַנְטוּנִינוּס וּמִקְרָא מְסַיְּעוֹ, "חַיִים וָחֶסֶד עָשִׂיתָ עִמָּדִי וּפְקֻדָּתְךָ שָׁמְרָה רוּחִי".