The Gemara (B. Berakhot 12) states that during Aseret Yeme Teshuba we conclude the Ata Kadosh blessing with Hamelekh Hakadosh and the Hashiba blessing with Hamelekh Hamishpat, and one who doesn't recite the required formula doesn't fulfill his obligation. The Gemara speaks about both in the same sentence, indicating one halakha for both. Commentators disagree on the implication of "doesn't fulfill his obligation". The majority of classical commentators (Rishonim) interpret it as it was eventually codified by Rabbi Joseph Karo in Shulhan Arukh OH 582:1 (1564):
If one realized he didn't mention Hamelekh Hakadosh or Hamelekh Hamishpat after concluding the Amida he repeats the Amida; if he realized in mid-Amida he returns. Regarding Hamelekh Hakadosh he returns to the beginning of the Amida [as the first three berakhot are one unit]; in the case of Hamelekh Hamishpat he returns to the beginning of Hashiba.
A minority view of classical commentators state that the Gemara's "doesn't fulfill his obligation" in this case does not mean repeat or return, but that the misvah was not performed appropriately. Both Shulhan Arukh and the Ramah, Rabbi Joseph Karo's younger contemporary who usually represents Ashkenazic practice in his glosses on Shulhan Arukh, ignored this minority view.
A third view, that of a single classical commentary, agrees with the first view as regards the meaning of "doesn't fulfill his obligation" (repeat/return), but maintains that in our days it doesn't apply to Hamelekh Hamishpat. He is of the opinion that in Talmudic days the all-year-long concluding phrase of Hashiba did not include the word Melekh; since somehow the text of the berakha was changed to include Melekh (Melekh Oheb Sedaka Umishpat), if one made a mistake during Aseret Yeme Teshuba and concluded as he does all year long, he would have mentioned the key words and fulfilled his obligation. According to this opinion it is not critical to say exactly Hamelekh Hamishpat. Ramah cited this view in his glosses on Shulhan Arukh (1569) and it has been the accepted Ashkenazic practice.
Many have wondered how it came about that the Ashkenazic practice followed one classic commentary who interprets the Gemara differently from the overwhelming majority of classical commentators.
Furthermore, the phrase established for Aseret Yeme Teshuba, Hamelekh Hamishpat, brings to an individual's consciousness one of the underlying motifs of these special days - the Almighty ascending His Throne of Justice to decide the fate of each individual. This thought is not expressed in the all-year-long phrase of "The King Who loves righteousness and justice". In contemplating the significance of Hamelekh Hamishpat, it is readily understandable why the Gemara concluded that one who didn't recite the required formula must repeat/return. To interpret the Gemara that it merely requires the mention of Melekh within a phrase that includes Mishpat, even if it doesn't express the thought of the King sitting on His Throne of Justice to judge mankind, does not appear congruent with having to repeat/return if not mentioned. *
It is well established from the writings of the great Sephardic rabbis throughout the centuries that virtually all Sephardic communities until recent times followed Shulhan Arukh on this as on most matters. In addition to the general commitment to Shulhan Arukh, this particular decision reflects the overwhelming majority of classical commentators and decisors including the three pillars of Jewish Law, the Rif (11th C.), the Rambam (12th C.) and the Rosh (13th C.).
A great Baghdadian rabbi, Rabbi Yoseph Hayyim, in his Ben Ish Hai (1898), followed the Ramah. His reason was "safek berakhot lehakel" - when there is a doubt if a berakha should be recited we are "lenient" regarding it and omit it, even if we thus depart from Shulhan Arukh. The concept behind this is that we should be extra-careful not to mention the name of the Almighty in vain. For purposes of creating such doubts in the area of pronouncing the Almighty's name, a small minority of opinions should suffice.
This decision has perplexed many rabbis including Hakham Obadiah Yosef. Shall a solitary opinion against a consensus create "safek berakhot lehakel" against Shulhan Arukh? Why not depart from Shulhan Arukh on Hamelekch Hakadosh also? Indeed, in that case there is a whole group of classical commentators who instruct not to repeat/return, as described in the second view above. Furthermore, if we follow "safek berakhot lehakel" against Shulhan Arukh when there is a small minority of dissenting opinion we would hardly be able to say any berakhot! (Elsewhere, the Ben Ish Hai himself recognized this problem in supporting the recital of certain berakhot against small minority opinions.)
Perhaps the most important question raised against viewing this matter as one of "safek berakhot lehakel" is that in the case of the Amida one cannot indiscriminately apply such a rule. Consider the dilemma. Upon realizing in the middle of the Amida that he didn't recite the appropriate concluding formula, one wouldn't be able to continue, for how can he recite the following berakhot -perhaps he should return as indicated by the majority view, and if he doesn't, proceeding onwards would be taking the Almighty's name in vain! Proceeding onwards in this case would transform even the earlier berakhot of the Amida to "vain" ones! Obviously, there are self-restricting limitations to being strict.
Although it doesn't answer the questions, perhaps the Ben Ish Hai considered an opinion cited in Ramah's glosses as authoritative as sufficient for invoking "safek berakhot lehakel".
It is evident that our Syrian community practice originally was as stated in Shulhan Arukh. The most authoritative of the post-Shulhan Arukh rabbis accepted by our community, Rabbi Haim Yoseph David Azoulai, (Rab Hida), in Birke Yoseph (1774), the Radbaz, the Pri Hadash, and almost all early Sephardic poskim, followed Shulhan Arukh on this. Two famous Syrian-Israeli rabbis of the early 20th Century, Rabbi Yoseph Yedid of Jerusalem and Rabbi Haim Sitton of Safed, concurred. The collection of halakhot assiduously studied by many of our community's learned men this past century, the Bet Obed (1843), also follows Shulhan Arukh on this. The 1885 edition of Selihot brought to press by Rabbi Yishaq Dayan of Aleppo, found in some community old-timers' homes, also follows Shulhan Arukh on this.
It is worthy of note that Rabbi Matloub Abady, a"h, a rabbi in Aleppo before emigrating to the United States, often stated that the Ben Ish Hai was not accepted as authoritative in Aleppo.
In the 1950's, Israeli-published siddurim with brief halakhot entered our community and for many years took over synagogue, school and home. On the Hamelekh Hamishpat issue they followed the Ben Ish Hai, so many conducted accordingly. Additionally, the works of the Ben Ish Hai and another great Baghdadian rabbi the Caf Hahaim, who also instructed not to repeat/return, became increasingly popular amongst laymen in the 50's. The entry of non-Syrian rabbis and teachers into the community over the past 40-50 years has also played a role as has the "cross-fertilization" of travellers. These forces influenced many changes in our Aleppo liturgy and customs, but this is not the place for such a discussion.
The Kol Yaaqob siddur merely informs to recite Hamelekh Hamishpat without instructions in case of omission.
* Rabbi Yaacov Schwarz interprets the Ramah as consistent with his position regarding one who recited the amida without concentration (kavana). Shulhan Arukh states that if one didn't have kavana in at least the first berakha he should repeat the amida. The Ramah disagrees as even the repetition will probably be without kavana. The allowance for everybody to recite the amida is itself a concession to maintain the halakha of praying, but it is appropriate to rely on any plausible interpretation to exempt repetition. The reason the Ramah didn't follow the minority view on Hamelekh Hakadosh is that the controversy is on interpreting the Gemara's language and the indication is clear to all like the majority.