According to Shaar Ephraim, this prayer was composed during the persecutions of 1075 and 1095 when thousands of Jews were killed in sanctification of God's Name.
אַב הָרַחֲמִים is said every Shabbos except: when the new moon is blessed, on Rosh Chodesh, on Yom Tov, on Chanukah or Purim, when there is a bridegroom, or when one whose son is to be circumcised on that day is present in the congrega- tion. Between Pesach and Shavuous, אַב הָרַחֲמִים is said in many congregations even on the Shabossos when the new month is blessed.
אַב הָרַחֲמִים Father of compassion,
שׁוֹכֵן מְרוֹמִים. Who dwells on high,
בְּרַחֲמָיו הָעֲצוּמִים. in His profound mercy,
הוּא יִפְקוֹד בְּרַחֲמִים He will be compassionately mindful of
הַחֲסִידִים the pious,
וְהַיְּ֒שָׁרִים וְהַתְּ֒מִימִים. the upright, and the blameless ones;
קְהִלּוֹת הַקֹּֽדֶשׁ the holy communities
שֶׁמָּסְ֒רוּ נַפְשָׁם who gave their lives
עַל קְדֻשַּׁת הַשֵּׁם. for the sanctification of the Divine Name.
הַנֶּאֱהָבִים וְהַנְּ֒עִימִים They were beloved and pleasant
בְּחַיֵּיהֶם in their lifetime,
וּבְמוֹתָם and in their death
לֹא נִפְרָֽדוּ. are not parted [from Him].202 Samuel 1:23.
מִנְּ֒שָׁרִים קַֽלּוּ They were swifter than eagles
וּמֵאֲרָיוֹת גָּבֵֽרוּ. and stronger than lions
לַעֲשׂוֹת רְצוֹן קוֹנָם to do the will of their Possessor
וְחֵֽפֶץ צוּרָם: and the desire of their Rock.
יִזְכְּ֒רֵם אֱלֹהֵֽינוּ לְטוֹבָה. Our God will recall them favorably
עִם שְׁאָר צַדִּיקֵי עוֹלָם. together with the other righteous of all time.
וְיִנְקוֹם נִקְמַת דַּם עֲבָדָיו And will avenge the blood of His servants
הַשָּׁפוּךְ: that has been shed.
כַּכָּתוּב בְּתוֹרַת משֶׁה As it is written in the Torah of Moses,
אִישׁ הָאֱלֹהִים. the man of God,
הַרְנִֽינוּ גוֹיִם עַמּוֹ “Sing [you] nations, [the praise] of His people,
כִּי דַם עֲבָדָיו יִקּוֹם. for the blood of His servants will He avenge,
וְנָקָם יָשִׁיב לְצָרָיו and vengeance will He repay to His foes;
וְכִפֶּר אַדְמָתוֹ and His land will be atoned
עַמּוֹ: [with the atonement] of His people.”21Deuteronomy 32:43, see Rashi.
וְעַל יְדֵי עֲבָדֶֽיךָ And by the hands of Your servants,
הַנְּ֒בִיאִים the Prophets,
כָּתוּב לֵאמֹר. it is written saying:
וְנִקֵּֽיתִי “I will cleanse them22God will forgive the nations for their wrongdoings but He will not forgive them for shedding Jewish blood.
דָּמָם לֹא נִקֵּֽיתִי. [but] for their blood,23Their blood refers to Jewish blood. I will not cleanse them,
וַיהֹוָה שֹׁכֵן בְּצִיּוֹן: and Adonoy [still] dwells in Zion.”24Joel 4:21.
וּבְכִתְבֵי הַקֹּדֶשׁ נֶאֱמַר And in the Holy Writings, it is said,
לָֽמָּה יֹאמְ֒רוּ הַגּוֹיִם “Why should the nations say,
אַיֵּה אֱלֹהֵיהֶם ‘Where is their God?'
יִוָּדַע בַּגּוֹיִם Let it be known among the nations,
לְעֵינֵֽינוּ before our eyes,25Before our eyes i.e. in our lifetime.
נִקְמַת דַּם עֲבָדֶֽיךָ the avenging of the blood of Your servants
הַשָּׁפוּךְ: that has been shed.”26Psalms 79:10.
וְאוֹמֵר And it says,
כִּי דוֹרֵשׁ דָּמִים “For He Who is concerned for the blood[shed],
אוֹתָם זָכָר He is mindful of them,
לֹא שָׁכַח צַעֲקַת עֲנָוִים: He has not forgotten the cry of the humble.”27Psalms 9:13.
❖וְאוֹמֵר And it says:
יָדִין בַּגּוֹיִם “He will judge the nations
מָלֵא גְוִיּוֹת [the battlefield will be] filled with [their] corpses.
מָֽחַץ רֹאשׁ עַל אֶֽרֶץ רַבָּה: He will crush heads on the earth many times.
מִנַּֽחַל בַּדֶּֽרֶךְ From the brook by the wayside
יִשְׁתֶּה will He drink;28God will be satisfied with the vengeance He will wreak upon the nations, as one is satisfied when he drinks from a brook at the wayside.—Metsudas Dovid
עַל כֵּן יָרִים ראשׁ: therefore [Israel] will hold its head high.29Psalms 11:6, 7. When God takes His vengeance, Israel will be vindicated and hold its head high with pride.