The district (?, gun) is today a geographical and statistical unit comprising one or several rural municipalities in Japan. It was used as an administrative unit in Japan in antiquity and between 1878 and 1921 and was roughly equivalent to the county of the United States, ranking at the level below prefecture and above town or village, same as city.
The district was initially called k?ri and has ancient roots in Japan. Although the Nihon Shoki says they were established during the Taika Reforms, k?ri was originally written ?. It was not until the Taih? Code that k?ri came to be written as ? (imitating the Chinese division). Under the Taih? Code, the administrative unit of province (?, kuni) was above district, and the village (? or ? sato) was below.
As the power of the central government decayed (and in some periods revived) over the centuries, the provinces and districts, although never formally abolished and still connected to administrative positions handed out by the Imperial court (or whoever controlled it), largely lost their relevance as administrative units and were superseded by a hierarchy of feudal holdings. In the Edo period, the primary subdivisions were the shogunate cities, governed by urban administrators (machi-bugy?), the shogunate domain (bakury?, usually meant to include the smaller holdings of Hatamoto, etc.), major holdings (han/domains), and there was also a number of minor territories such as spiritual (shrine/temple) holdings; while the shogunate domain comprised vast, contiguous territories, domains consisted of generally only one castle and castle town, usually a compact territory in the surrounding area, but beyond that sometimes a string of disconnected exclaves and enclaves, in some cases distributed over several districts in several provinces. For this reason alone, they were impractical as geographical units, and in addition, Edo period feudalism was tied to the nominal income of a territory, not the territory itself, so the shogunate could and did redistribute territories between domains, their borders were generally subject to change, even if in some places holdings remained unchanged for centuries. Provinces and districts remained the most important geographical frame of reference throughout the middle and early modern ages up to the restoration and beyond - initially, the prefectures were created in direct succession to the shogunate era feudal divisions and their borders kept shifting through mergers, splits and territorial transfers until they reached largely their present state in the 1890s.
Cities (-shi), since their introduction in 1889, have always belonged directly to prefectures and are independent from districts. Before 1878, districts had subdivided the whole country with only few exceptions (Edo/Tokyo as shogunate capital and some island groups). In 1878, the districts were reactivated as administrative units, but the major cities were separated from the districts. All prefectures (at that time only -fu and -ken) were - except for some remote islands - contiguously subdivided into [rural] districts/counties (-gun) and urban districts/cites (-ku), the precursors to the 1889 shi. Geographically, the rural districts were mainly based on the ancient districts, but in many places they were merged, split up or renamed, in some areas, prefectural borders went through ancient districts and the districts were reorganized to match; urban districts were completely separated from the rural districts, most of them covered one city at large, but the largest and most important cities, the Edo period "three capitals" Edo/Tokyo, Kyoto, Osaka comprised several urban districts. (This refers only to the city areas which were not organized as a single administrative unit before 1889, not the prefectures Tokyo, Kyoto and Osaka which had initially been created in 1868 as successor to the shogunate city administrations, but were soon expanded to surrounding shogunate rural domain and feudal holdings and by 1878 also contained rural districts and in the case of Osaka, one other urban district/city from 1881.)
District administrations were set up in 1878, but district assemblies were only created in 1890 with the introduction of the district code (gunsei) as part of the Prussian-influenced local government reforms of 1888-90. From the 1890s, district governments were run by a collective executive council (gun-sanjikai, ?), headed by the appointed district chief (gunch?) and consisting of 3 additional members elected by the district assembly and one appointed by the prefectural governor - similar to cities (shi-sanjikai, headed by the mayor) and prefectures (fu-/ken-sanjikai, headed by the governor).
In 1921, Hara Takashi, the first non-oligarchic prime minister (although actually from a Morioka domain samurai family himself, but in a career as commoner-politician in the House of Representatives), managed to get his long-sought abolition of the districts passed - unlike the municipal and prefectural assemblies which had been an early platform for the Freedom and People's Rights Movement before the Imperial Diet was established and became bases of party power, the district governments were considered to be a stronghold of anti-liberal Yamagata Aritomo's followers and the centralist-bureaucratic Home Ministry tradition. The district assemblies and governments were abolished a few years later.
As of today, towns and villages also belong directly to prefectures; the districts no longer possess any administrations or assemblies since the 1920s, and therefore also no administrative authority - although there was a brief de facto reactivation of the districts during the Pacific War in the form of prefectural branch offices (called chih? jimusho, , "local offices/bureaus") which generally had one district in their jurisdiction. However, for geographical and statistical purposes, districts continue to be used and are updated for municipal mergers or status changes: if a town or village (countrywide: >15,000 in 1889, <1,000 today) is merged into or promoted to a [by definition: district-independent] city (countrywide: 39 in 1889, 791 in 2017), the territory is no longer counted as part of the district. In this way, many districts have become extinct, and many of those that still exist contain only a handful of or often only one remaining municipality as many of today's towns and villages are also much larger than in the Meiji era. The districts are used primarily in the Japanese addressing system and to identify the relevant geographical areas and collections of nearby towns and villages.
Because district names had been unique within a single province and as of 2008 prefecture boundaries are roughly aligned to provincial boundaries, most district names are unique within their prefectures.
Hokkaid? Prefecture, however, came much later to the ritsury? provincial system, only a few years before the prefectural system was introduced, so its eleven provinces included several districts with the same names: