שֹׁפְטִ֣ים וְשֹֽׁטְרִ֗ים תִּֽתֶּן־לְךָ֙ בְּכׇל־שְׁעָרֶ֔יךָ אֲשֶׁ֨ר יְהֹוָ֧ה אֱלֹהֶ֛יךָ נֹתֵ֥ן לְךָ֖ לִשְׁבָטֶ֑יךָ וְשָׁפְט֥וּ אֶת־הָעָ֖ם מִשְׁפַּט־צֶֽדֶק׃
You shall appoint magistrates and officials for your tribes, in all the settlements that the Eternal your God is giving you, and they shall govern the people with due justice.
Torah Temimah points to Makkot 7a.
בכל שעריך. יכול בארץ אין בחו״ל לא, ת״ל (פ׳ מסעי) והיו אלה לכם לחקת משפט לדורתיכם, למדנו לסנהדרין שנוהגת בארץ ובחו״ל, א״כ מה ת״ל בכל שעריך – לומר לך, בשעריך אתה מושיב בתי דינים בכל פלך ובכל עיר, ובחו״ל אי אתה מושיב אלא בכל פלך בלבד.
English: “In all your gates.” One might think this applies only in the Land of Israel and not outside the Land. Therefore the verse states (in Parashas Masei) “These shall be for you a statute of judgment for your generations,” teaching that the Sanhedrin operates both in the Land and outside the Land. What then does “in all your gates” teach? In the Land you establish courts in every district and every city; outside the Land you establish them only in every district.
Makkot 7a distinguishes the scope of the obligation: full local courts inside the Land of Israel versus district-level courts in the Diaspora.
Derash on the verse (Bavli sugya) — not a formal named middah of the 13. The verse is limited by a parallel verse that extends the institution of courts beyond the Land while restricting their density outside it.
Inside the Land of Israel courts must be established in every city and district; outside the Land the obligation is only for each district.