The Shulchan Aruch · Orach Chayim
אורח חיים תקע״וOrach Chayim 576
Siman 576 of 697 in Orach Chayim — 16 se'ifim
הלכות תעניתLaws of Fast Days· siman 576
Se’if 1א׳
כְּשֵׁם שֶׁמִּתְעַנִּים וּמַתְרִיעִים עַל הַגְּשָׁמִים כָּךְ מִתְעַנִּים עַל שְׁאָר הַצָּרוֹת; כְּגוֹן עַכּוּ"ם שֶׁבָּאוּ לַעֲרֹךְ מִלְחָמָה עִם יִשְׂרָאֵל, אוֹ לִטֹּל מֵהֶם מַס, אוֹ לִקַּח מִיָּדָם אֶרֶץ, אוֹ לִגְזֹר עֲלֵיהֶם צָרָה אֲפִלּוּ בְּמִצְוָה קַלָּה, הֲרֵי אֵלּוּ מִתְעַנִּין וּמַתְרִיעִין עַד שֶׁיְּרֻחַמוּ; וְכָל הֶעָרִים שֶׁסְבִיבוֹתֵיהֶם מִתְעַנִּים אֲבָל אֵין מַתְרִיעִין, אֶלָּא אִם כֵּן תָּקְעוּ לְהִתְקַבֵּץ לְעֶזְרָתָם; וַאֲפִלּוּ לֹא בָּאוּ אֶלָּא לַעֲבֹר דֶּרֶךְ אַרְצָם, שֶׁאֵין לָהֶם מִלְחָמָה עִמָּהֶם אֶלָּא עַל עַכּוּ"ם אֲחֵרִים, וְעוֹבְרִים עַל מְקוֹם יִשְׂרָאֵל מִתְעַנִּין וּמַתְרִיעִין.
Concerning what matters they fast, proclaim, and in it, there are sixteen clauses. 1. Just as they fast and proclaim for rain, so too, they fast for other troubles, such as the heathens who come to wage war against Israel, or if they impose a tax on them, take land from them, or decree trouble upon them, even if it's a minor mitzvah. These [cities] fast and proclaim, and [others] around them also fast, but they do not proclaim unless the enemy has come and they have blown the shofar to gather for their assistance. Even if they only came to pass through their land, causing no war except against other heathens later on, and those who pass through the land of Israel fast and proclaim.
Se’if 2ב׳
וְכֵן עַל הַדֶּבֶר. אֵיזֶהוּ דֶּבֶר, עִיר שֶׁיֵּשׁ בָּהּ ת"ק רַגְלִי וְיָצְאוּ מִמֶּנָּה שְׁלֹשָׁה מֵתִים בִּשְׁלֹשָׁה יָמִים זֶה אַחַר זֶה, הֲרֵי זֶה דֶּבֶר. יָצְאוּ בְּיוֹם א' אוֹ בְּד' יָמִים, אֵין זֶה דֶּבֶר. הָיוּ בָּהּ אֶלֶף וְיָצְאוּ מִמֶּנָּה שִׁשָּׁה מֵתִים בְּג' יָמִים זֶה אַחַר זֶה, הֲרֵי זֶה דֶּבֶר. יָצְאוּ בְּיוֹם אֶחָד אוֹ בְּאַרְבָּעָה יָמִים, אֵין זֶה דֶּבֶר; וְכֵן לְפִי חֶשְׁבּוֹן זֶה; וְאֵין הַנָּשִׁים וְהַקְּטַנִּים וּזְקֵנִים שֶׁשָּׁבְתוּ מִמְּלָאכָה בִּכְלַל מִנְיַן אַנְשֵׁי הַמְּדִינָה לְעִנְיָן זֶה; הָיָה דֶּבֶר בְּאֶרֶץ יִשְׂרָאֵל, מִתְעַנִּין שְׁאָר גָּלֻיּוֹת עֲלֵיהֶם וְדַוְקָא דְּאִיכָּא דָּבָר בְּכֻלָּהּ וְלֹא בְּמִקְצָתָהּ (ר"ן פ"ג דְּתַעֲנִית). הָיָה דֶּבֶר בַּמְּדִינָה, וְשַׁיָּרוֹת הוֹלְכוֹת וּבָאוֹת מִמֶּנָּה לִמְדִינָה אַחֶרֶת, שְׁתֵּיהֶן מִתְעַנּוֹת אַף עַל פִּי שֶׁהֵן רְחוֹקוֹת זוֹ מִזּוֹ.
2. The same applies for a plague. What qualifies as a plague? If a city has 500 infantry and three die in three consecutive days, one each day, this is a plague. If they die in one day or over four days, this is not a plague. If there are 1000 and six die in three consecutive days, this is a plague. If they die on one day or over four days, this is not a plague. The calculation is like this. Women, children, and elders who no longer work are not considered citizens for this matter. If there is a plague in the land of Israel, the Disapora fasts for them (provided there is a plague in the whole land and not just in part of it (Ra"n chapter 3 of Taanit)). If there is plague in a state and there is another state that trades with it, both fast even if they are distant.
Se’if 3ג׳
וְאִם הָיָה דֶּבֶר בַּחֲזִירִים, מִתְעַנִּין, מִפְּנֵי שֶׁמֵּעֵיהֶם דּוֹמִים לְשֶׁל בְּנֵי אָדָם; וְכָל שֶׁכֵּן אִם הָיָה דֶּבֶר בְּעַכּוּ"ם וְלֹא בְּיִשְׂרָאֵל, שֶׁמִּתְעַנִּים.
3. If there was a plague concerning pigs, one would fast because their organs are similar to those of humans, and certainly so if the matter pertained to non-Jews and not to Jews, they would still fast.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0