The 362nd prohibition is that we are forbidden from appointing over ourselves a king who is not of Jewish lineage, even if he is a ger tzedek (righteous convert).

The source of this prohibition is G‑d's statement1 (exalted be He), "You may not appoint a foreigner who is not one of your brethren."

The Sifri2 says: "The verse, 'You may not appoint a foreigner,' constitutes a prohibition."

It is also prohibited to appoint a ger tzedek to any other position, whether in Torah3 or in government,4 unless his mother is Jewish. From this that G‑d (exalted be He) said,5 "You shall appoint for yourselves a king among your brethren," our Sages derived,6 "All appointments you make over yourselves must be from among your brethren."

The position of king is unique in that it was bestowed upon Dovid [and his descendants], as you know from the words of the Prophets. Our Sages said explicitly,7 "Kingship was bestowed upon Dovid," and so too his descendants for all generations.8 For those who believe in the Torah of Moshe Rabbeinu, a king must descend from Dovid and Shlomo. One who is not from this distinguished lineage is considered a "foreigner" as far as kingship is concerned, just as any Jew who does not descend from Aaron is considered a "foreigner" as far as serving in the Holy Temple. This is clear beyond any doubt.

The details of this mitzvah are explained in many passages in tractate Yevamos,9 Sanhedrin,10 Sotah,11 and Niddah.12