The custom to pray for the welfare of the government is mentioned in Kol Bo and Avudraham. The latter writes, “After the reading of the Torah, it is customary to bless the king and pray to God that he be given might and power over his enemies. This prayer is based on Jeremiah 29:7, “Seek the peace of the city where I have sent you into exile, and pray to Adonoy in its behalf; for in its peace, you will have peace.” We also find reference to such prayer in the Mishna, (Maseches Avos 3:2), “Rabbi Chanina, Deputy Kohein Gadol, says: Pray for the welfare of the government, because if people had no fear of it, they would swallow each other alive.”
הַנּוֹתֵן תְּשׁוּעָה לַמְּ֒לָכִים. He Who grants deliverance to kings,
וּמֶמְשָׁלָה לַנְּ֒סִיכִים. and dominion to princes,
מַלְכוּתוֹ מַלְכוּת כָּל־עוֹלָמִים. His kingship is a kingship of all worlds;
הַפּוֹצֶה אֶת־דָּוִד עַבְדּוֹ He [Who] rescued David, His servant,
מֵחֶֽרֶב רָעָה. from the evil sword,
הַנּוֹתֵן בַּיָּם דֶּֽרֶךְ. Who put a road through the sea,
וּבְמַֽיִם עַזִּים נְתִיבָה. and a path amid the mighty waters;
הוּא יְבָרֵךְ וְיִשְׁמֹר וְיִנְצֹר. may He bless, preserve, and guard,
וְיַעֲזֹר וִירוֹמֵם וִיגַדֵּל help, exalt, and make great,
וִינַשֵּׂא לְמַֽעְלָה and raise high
אֶת נְשִׂיא אַרְצוֹת הַבְּ֒רִית the President of these United States,
וּמִשְׁנֵֽהוּ and the Vice President.
מֶֽלֶךְ מַלְכֵי הַמְּ֒לָכִים בְּרַֽחֲמָיו May the Supreme King of kings in His mercy,
יְחַיֵּם וְיִשְׁמְ֒רֵם. sustain them in life and preserve them;
וּמִכָּל צָרָה וְיָגוֹן וָנֶֽזֶק and from all distress, sorrow, and hurt,
יַצִּילֵם. may He save them.
מֶֽלֶךְ מַלְכֵי הַמְּ֒לָכִים בְּרַֽחֲמָיו May the Supreme King of kings in His mercy,
יִתֵּן בְּלִבָּם רַחֲמָנוּת. instill in their hearts compassion
לַעֲשׂוֹת טוֹבוֹת עִמָּֽנוּ. to do good with us
וְעִם כָּל־יִשְׂרָאֵל. and with all Israel.
בִּימֵיהֶם וּבְיָמֵֽינוּ In their days and in ours,
תִּוָּשַׁע יְהוּדָה. may Judah be delivered
וְיִשְׂרָאֵל יִשְׁכֹּן לָבֶֽטַח. and Israel dwell in security,
וּבָא לְצִיּוֹן גּוֹאֵל. and the Redeemer come to Zion.
וְכֵן יְהִי רָצוֹן May this be His will
וְנֹאמַר אָמֵן: and let us say, Amein.