The Gemara discusses the danger of pairs and the role of demons in the practices and protective norms of the Talmudic period. It supplies the primary Chazal background for later interpretations of demonology.
אָמַר רַב יוֹסֵף, אָמַר לִי יוֹסֵף שֵׁידָא: אַשְׁמְדַאי מַלְכָּא דְשֵׁידֵי — מְמוּנֶּה הוּא אַכּוּלְּהוּ זוּגֵי, וּמַלְכָּא לָא אִיקְּרִי מַזִּיק. אִיכָּא דְּאָמְרִי לַהּ לְהַאי גִּיסָא: אַדְּרַבָּה, מַלְכָּא [רַתְחָנָא הוּא], מַאי דְּבָעֵי עָבֵיד, שֶׁהַמֶּלֶךְ פּוֹרֵץ גָּדֵר לַעֲשׂוֹת לוֹ דֶּרֶךְ וְאֵין מוֹחִין בְּיָדוֹ. אָמַר רַב פָּפָּא, אָמַר לִי יוֹסֵף שֵׁידָא: בִּתְרֵי קָטְלִינַן, בְּאַרְבְּעָה לָא קָטְלִינַן, בְּאַרְבְּעָה מַזְּקִינַן. בִּתְרֵי, בֵּין בְּשׁוֹגֵג בֵּין בְּמֵזִיד. בְּאַרְבְּעָה, בְּמֵזִיד — אִין, בְּשׁוֹגֵג — לָא. וְאִי אִישְׁתְּלִי וְאִיקְּרִי וּנְפַק, מַאי תַּקַּנְתֵּיהּ? לִינְקוֹט זַקְפָּא דִידֵיהּ דְּיַמִּינֵיהּ בִּידָא דִשְׂמָאלֵיהּ וְזַקְפָּא דִשְׂמָאלֵיהּ בִּידָא דְיַמִּינֵיהּ, וְנֵימָא הָכִי: ״אַתּוּן וַאֲנָא — הָא תְּלָתָא״. וְאִי שְׁמִיעַ לֵיהּ דְּאָמַר: ״אַתּוּן וַאֲנָא — הָא אַרְבְּעָה״, נֵימָא לֵיהּ: ״אַתּוּן וַאֲנָא — הָא חַמְשָׁה״. וְאִי שְׁמִיעַ לֵיהּ דְּאָמַר: ״אַתּוּן וַאֲנָא — הָא שִׁיתָּא״, נֵימָא לֵיהּ: ״אַתּוּן וַאֲנָא — הָא שִׁבְעָה״. הֲוָה עוֹבָדָא עַד מְאָה וְחַד, וּפְקַע שֵׁידָא.
Rav Yosef said: Yosef the Demon said to me: Ashmedai, the king of the demons, is appointed over all who perform actions in pairs, and a king is not called a harmful spirit. A king would not cause harm. Consequently, there is no reason to fear the harm of demons for having performed an action in pairs. Some say this statement in this manner: On the contrary, he is an angry king who does what he wants, as the halakha is that a king may breach the fence of an individual in order to form a path for himself, and none may protest his action. Similarly, the king of demons has full license to harm people who perform actions in pairs. Rav Pappa said: Yosef the Demon said to me: If one drinks two cups, we demons kill him; if he drinks four, we do not kill him. But this person who drank four, we harm him. There is another difference between two and four: With regard to one who drinks two, whether he did so unwittingly or intentionally, we harm him. With regard to one who drinks four, if he does so intentionally, yes, he is harmed; if he does so unwittingly, no, he will not be harmed. The Gemara asks: And if one forgets and it happens that he goes outside after having drunk an even number of cups, what is his solution? The Gemara answers: He should take his right thumb in his left hand, and his left thumb in his right hand, and say as follows: You, my thumbs, and I are three, which is not a pair. And if he hears a voice that says: You and I are four, which makes a pair, he should say to it: You and I are five. And if he hears it say: You and I are six, he should say to it: You and I are seven. The Gemara relates that there was an incident in which someone kept counting after the demon until he reached a hundred and one, and the demon burst in anger.