מִצְוַת עֲשֵׂה שֶׁל תּוֹרָה לְמַנּוֹת שׁוֹפְטִים וְשׁוֹטְרִים בְּכָל מְדִינָה וּמְדִינָה וּבְכָל פֶּלֶךְ וּפֶלֶךְ שֶׁנֶּאֱמַר (דברים טז יח) "שֹׁפְטִים וְשֹׁטְרִים תִּתֶּן לְךָ בְּכָל שְׁעָרֶיךָ".
וֹאֵין אָנוּ חַיָּבִין לְהַעֲמִיד בָּתֵּי דִּינִים בְּכָל פֶּלֶךְ וּפֶלֶךְ וּבְכָל עִיר וָעִיר אֶלָּא בְּאֶרֶץ יִשְׂרָאֵל בִּלְבַד. אֲבָל בְּחוּצָה לָאָרֶץ אֵינָן חַיָּבִין לְהַעֲמִיד בֵּית דִּין בְּכָל פֶּלֶךְ וּפֶלֶךְ שֶׁנֶּאֱמַר (דברים טז יח) "תִּתֶּן לְךָ בְּכָל שְׁעָרֶיךָ אֲשֶׁר ה' אֱלֹקֶיךָ נֹתֵן לְךָ לִשְׁבָטֶיךָ":
It is a positive Scriptural commandment to appoint judges and enforcement officers in every city and in every region, as Deuteronomy 16:18 states: "Appoint judges and enforcement officers in all your gates....We are obligated to appoint courts in every region and in every city only in Eretz Yisrael. Outside of Israel, by contrast, we are not obligated to appoint courts in every region. This is derived from the continuation of the above verse: "Appoint...in all your gates which God your Lord is giving you for your tribes."
וּמַעֲמִידִין בְּכָל עִיר וָעִיר מִיִּשְׂרָאֵל שֶׁיֵּשׁ בָּהּ מֵאָה וְעֶשְׂרִים אוֹ יוֹתֵר סַנְהֶדְרִי קְטַנָּה וְיוֹשֶׁבֶת בְּשַׁעַר הָעִיר שֶׁנֶּאֱמַר (עמוס ה טו) "וְהַצִּיגוּ בַשַּׁעַר מִשְׁפָּט". וְכַמָּה יִהְיֶה מִנְיָנָם עֶשְׂרִים וּשְׁלֹשָׁה דַּיָּנִים
In addition, in every city in Israel in which their are 120 or more adult males, we appoint a minor Sanhedrin. They hold court at the entrance to the city, as implied by Amos 5:15: "And you shall present judgment in your gates." How many judges should be in such a court? 23.