County magistrate (simplified Chinese: ; traditional Chinese: ; pinyin: or simplified Chinese: ; traditional Chinese: ; pinyin: ) sometimes called local magistrate, in imperial China was the official in charge of the xian, or county, the lowest level of central government. The magistrate was the official who had face-to-face relations with the people and administered all aspects of government on behalf of the emperor. Because he was expected to rule in a disciplined but caring way and because the people were expected to obey, the county magistrate was informally known as the Fumu Guan (Chinese: ; pinyin: ), the "Father and Mother" or "parental" official.
The emperor appointed magistrates from among those who passed the imperial examinations or had purchased equivalent degrees. Education in the Confucian Classics indoctrinated these officials with a shared ideology that helped to unify the empire, but not with practical training. A magistrate acquired specialized skills only after assuming office. Once in office, the magistrate was caught between the demands of his superiors and the needs and resistance of his often unruly constituents. Promotion depended on the magistrate's ability to maintain peace and lawful order as he supervised tax collection, roads, water control, and the census; handled legal functions as both prosecutor and judge; arranged relief for the poor or afflicted; carried out rituals; encouraged education and schools; and performed any further task the emperor chose to assign. Allowed to serve in any one place for only three years, he was also at the mercy of the local elites for knowledge of the local scene. There was a temptation to postpone difficult problems to the succeeding magistrate's term or to push them into a neighboring magistrate's jurisdiction. The Yongzheng emperor praised the magistrate: "The integrity of one man involves the peace or unhappiness of a myriad."  But a recent historian said of the magistrate that "if he had possessed the qualifications for carrying out all his duties, he would have been a genius. Instead, he was an all-around blunderer, a harassed Jack-of-all trades...." 
The Republic of China (1912 - ) made extensive reforms in county government, but the position of magistrate was retained. . Under the People's Republic of China (1949 - ) the office of county magistrate, sometimes translated as "mayor," was no longer the lowest level of the central government, which extended its control directly to the village level.
From ancient times until the end of the Tang dynasty in the eighth century, the office was called traditional Chinese: ; simplified Chinese: ; pinyin: . In the following dynasties, the office was called Zhixian (; ; ) until 1928, when the title was changed to ; ; . 
The county (xian) was established as the basic unit of local government around the year 690 B.C.E., during the Warring States period marked by competition between small-scale states. The Qin empire unified much of China in 221 BCE. and established the jun-xian Chinese: ; pinyin: (prefecture/ county) system, which divided the realm into jun (prefectures or commanderies) and xian (counties). Local administrators appointed by the central government replaced the leaders of feudal cities. In spite of many changes, the xian remained the basic unit of local government until the 20th century.
Before the Qin unification in 221 BCE, local officials inherited office, which strengthened great families against the central government. After that unification, no official except the emperor was allowed to inherit or bequeath office. The control of local government then became a contest between the central bureaucracy, which represented the interests of the emperor, and local nobility and elites. Imperial power undercut the local aristocracy by appointing scholar officials chosen by merit through the examination system who were not necessarily of noble descent. The Han dynasty regularized the position, and initiated the "rule of avoidance", which forbade a magistrate to serve in his home county because of the danger of nepotism and favoritism to family or friends. After the Sui dynasty in the sixth century, the rule of avoidance was strictly enforced; in later dynasties a magistrate could serve only up to four years in any one place before being transferred.
The magistrate was supervised by the prefect (zhifu) or the equivalent, who in turn was ordinarily under the circuit intendant (dao), or perhaps a circuit intendant with such special responsibilities as waterworks, grain, or salt. Above them were the provincial administrators and the governor. Above all of these, of course, was the central government and the emperor. Each of these layers could issue orders to the local magistrate and each required reports and memorials from him.
The county magistrate supervised units of control below the county level. These included village elders, local institutions, and self-rule organizations, especially the township (xiang), which had been made formal under the Han dynasty, and the baojia system, a system of mutual responsibility formally organized by Wang Anshi in the 11th century, during the Song dynasty. Under Mongol rule in the Yuan dynasty, the county magistrates were all Mongol, though their subordinates were Han Chinese. In the Ming and Qing dynasties the growth of the economy and increase in population led magistrates to hire administrative secretaries and to rely on local elite families, or scholar-gentry.These local elites had friends whose influence could counteract the magistrate if he displeased them.
When the People's Republic was founded in 1949, the central government once again appointed local officials who wielded civil, criminal, and bureaucratic power. Some suggest that workers and villagers feel they cannot question the authority of these "father and mother" officials, making corruption easier and dissent harder.
The magistrate's responsibilities were broad but not clearly defined. The emperors believed that Heaven entrusted their government with relations with the physical universe, cosmic morality, human institutions, and social harmony, and the magistrate was his representative in all these matters.
Yet the magistrate's power was circumscribed, as reflected in the saying "Heaven is high and the emperor far away." The county government bureaucracy was thin in relation to the population, and the official staff of a larger county might consist only of a magistrate, a vice-magistrate, perhaps an assistant magistrate or recorder, and the captain of the militia. As early as the 12th century this small group was expected to supervise a population that could easily be 150,000 in the more densely populated sections of the country. In later dynasties, magistrates took on larger staffs. In the counties of the prosperous Lower Yangzi valley, the total staff of clerks, secretaries, yamen runners, medical examiners, jailers, and other such lesser employees might be some 500 people for a population of 100,000 to 200,000. The eminent historian Kung-chuan Hsiao, however, argued that local government became more despotic and the county magistrate had unlimited powers to control the people.
The county government collected the land tax, grain tribute, and all other taxes except the customs duties and likin, which were introduced in the 19th century. The provincial treasurer prepared the quotas for the land and labor services tax due from each county according to the number of ding (male adults), as well as other taxes, and in theory adjusted the rates every ten years. The magistrate also had responsibility for local infrastructure and communications. Each village was required to contribute free labor, or the corvee, for building and maintaining local roads, canals, and dams under the supervision of the county government.
Taxes on the land were collected in silver, which was brought to the magistrate's court, where it was counted and recorded in his presence. He was allowed to keep a specified amount for local functions such as salaries, stipends for government school students, and relief for the poor, then forward the rest to the provincial treasurer. In later dynasties, the money assigned for local functions was too little, and magistrates imposed further fees and taxes, such as title deed taxes, brokerage tax, pawnshop tax, and many more.
After tax collection, law enforcement and legal disputes occupied the most of the magistrate's time and energy. Social harmony was paramount. The annual review for promotion graded the magistrate on his ability to catch thieves and prosecute robberies. One demerit was given for every five cases in which he arrested fewer than half the offenders and one merit for every five cases in which he arrested more than half.
The magistrate lived, worked, and held court in the yamen, a walled compound which housed the local government. In theory, any commoner could submit a lawsuit, petition, or complaint after striking a large bell at the entrance to the compound. The magistrate administered both judicial and administrative law. Scholars in the West once felt that the magistrate did not often become involved in civil disputes and that citizens were reluctant to bring them to the local courts, but research has shown that in fact local society was extremely litigious and that the local government was involved in all types of disputes.
Legal systems in some parts of the world distinguish civil, criminal, and administrative law, but under the Chinese legal system, the magistrate administered both judicial and administrative law.The magistrate was not allowed arbitrary decisions or to rely on local customary law but was constrained both by imperial edicts, which had the force of law, and the law codes. These dynastic law codes, such as the Tang Code or the Great Qing Code, included both civil law and criminal law. Cases ranged from murder and theft to accusations that a neighbor did not tie his horse or dog or that someone had been kicked or bitten. Litigants also went to the magistrate with disputes over marriage, adoption, inheritance, and land, and these often had consequences for country revenue or taxes and tax collection. The Codes described offenses in detail, but the magistrate was also allowed to make an analogy to an existing provision of the code by using the rule: "Everyone who does that which ought not to be done will receive forty strokes of the light bamboo. If the matter is adjudged to more serious, he will be punished by eighty strokes with the heavy bamboo." Death sentences under the Qing were reviewed by the emperor, and serious cases of any nature could be appealed or reviewed, sometimes even to the emperor himself.
The magistrate, as in the inquisitorial system of continental European law, was both prosecutor and judge. He decided which cases to accept, directed the gathering of evidence and witnesses, then conducted the trial, including the use of torture. The magistrate was the sole judge of guilt or innocence and determined the punishment or compensation. Still, his decisions could be reviewed by higher officials, even up to the emperor in capital cases. Since he could be reprimanded for not investigating thoroughly, for not following correct procedure, or even for writing the wrong character, magistrates in later dynasties hired specialized clerks or secretaries who had expertise in the law and bureaucratic requirements.
Yet law was not simply a matter of codes and procedures. Law was understood to reflect the moral universe, and a criminal or civil offense would throw that universe out of balance in a way that only just punishment could restore. The official Five Punishments (wu xing) prescribed under the Qing Code included beating with the light bamboo, beating with the heavy bamboo, penal servitude, exile, and execution. In calibrating punishment, the magistrate had to take into account not only the nature of the offense but the relation between the guilty party and the victim. An offense by a son against a father was far more serious than one by a father against a son, likewise an offense by a wife or other member of the family.
The magistrate's role in practice faced many other constraints. The runners and yamen officials who were sent to investigate a crime were locals, often in league with the criminals. Magistrates commonly would therefore set a deadline for bringing in the criminals, threatening to take the policeman's family members as hostage if the deadline was not met. When the accused was brought before him, the magistrate could use torture, such as flogging or making the defendant kneel on an iron chain, but there were clear restrictions. The instruments had to be of a standard size and individually approved by the next higher yamen, and some could not be used on women or people over the age of seventy. The magistrate could order the use of the ankle-squeezer, for instance, only in cases of murder and robbery, and its use had to be specifically reported to the higher level. Some officials avoided the use of torture because they feared that it would produce false confessions. The magistrate had to make sure that any confession was recorded accurately, word for word, to prevent the clerk from introducing intentional errors that might prejudice the case. The magistrate himself could be punished if he invoked the wrong law or imposed a sentence that was either too harsh or too lenient.
The magistrate oversaw and supported but did not administer education. Primary schools were established by families, temples, villages, or clans and were entirely private in their organization and finance. But the curriculum was almost entirely based on the Confucian texts needed to pass the imperial exams. The magistrate under the Qing dynasty conducted the reading of the Sacred Edict and conducted ceremonies and rituals, especially in time of drought, famine, or disaster.
The magistrate's wide-ranging duties in dealing with larger and larger populations required the help of secretaries, clerks, prison guards, and runners, but there was no budget to pay for this staff. Instead, the magistrate paid his secretaries from his own pocket, which he was expected to refill from local sources, and the other staff were expected to collect fees from those who were unlucky enough to come in contact with them. These fees might be arbitrary and extortionate, and in later dynasties corruption was widespread.
Local government in the Ming and Qing dynasties accumulated responsibilities without increased resources. As the population grew, the number of counties remained roughly the same, with populations that could grow to perhaps 200,000. Ming rulers tightened the rule of avoidance which prevented magistrates from serving in their home districts, where it was justifiably feared that they would favor their friends and families, and the term of office was generally limited to two or three years. These rules ran the danger of posting magistrates to unfamiliar areas where they could not speak the local dialect and could not accumulate knowledge of local circumstances. The Qing government continued the Ming practice of requiring the magistrate to pay his subordinates from local taxes, not central government revenue; clerks, runners, jailers and such collected "informal fees" from the people. Confucian ideals also held that the state should stay out of the lives of the common people, who were to carry out public security functions on their own. The village head was responsible for tax collection, and the magistrate held him personally responsible for any shortfall.
Under the Qing dynasty (1644-1911), the last dynasty of imperial rule, local government became even more tightly stretched as population and wealth grew but government administrative institutions - and tax revenue - did not. The magistrate was in a difficult situation. His salary had not risen with the long-term inflation. In the 1720s the Yongzheng Emperor allowed the magistrate to deduct "meltage fees" from the land tax he was required to remit, but this did not address the structural problem. The unintended result was that by the early 19th century, major functions of local government had been abandoned by harried and underpaid magistrates and left to the gentry, who mediated disputes, supervised schools and irrigation works, organized local militia, and even collected taxes. Although magistrates were grateful to have this help, the local gentry often used these functions to reward themselves and punish their enemies.
Magistrates in the Qing, however, also became more professional in several respects. They studied administration as a craft rather than something which a cultivated Confucian scholar-bureaucrat was expected to perform on the basis of moral training and knowledge of the Confucian classics. Since the emperor, in order to reward loyalty, increased the quota of those who were allowed to pass the exams without increasing the number of positions, there came to be more degree holders than there were entry level appointments. Many of these unassigned men took positions as secretaries or clerks to county magistrates, forming a virtual sub-profession of experts on various aspects of the law, water-works, taxation, or administration. Others, especially those who held only lower degrees, became tutors or local school teachers with little prestige or adequate income.
The late Qing reforms of the early 20th century made basic changes. With the abolition of the centrally administered examination system, magistrates came to be selected by a local or ad hoc examinations, at least in theory, though recommendation and personal relations were more important in practice. The law of avoidance remained in effect, though it too was no longer enforced rigorously, and the political chaos of the period was reflected in rapid turnover and shorter terms of office. One study found that most magistrates were appointed by the militarists who controlled the area.  In the years leading up to the founding of the Nationalist government in 1928, however, there was a noticeable improvement in the education and technical training of the magistrates, particularly in law and administration. The study also concluded that the civilian bureaucracy became more and more militarized.
The County Organic Law, passed by the Nationalist government in 1928, defined the county as the basic level of government, and stipulated that the county magistrate, now called xianzhang, would be appointed by the provincial authorities. The county was supervised also by the Nationalist Party, which operated in parallel with the county government, an arrangement in accordance with the Party's Leninist structure. In addition, the new government organized a larger bureaucracy at the local level. 
After the Chinese Communist Revolution of 1949, local government took far more control of village life than had ever been possible in Chinese history, but local officials still faced many of the same problems as county magistrates under the empire. One foreign scholar wrote from his observations in 2015 that "grass-roots level civil servants are still seen as paternalistic 'father mother officials,' who are expected to take care of the ordinary people, enjoy a high degree of authority, but at the same time an equally high degree of mistrust." 
The magistrate was the hero in much popular fiction. The "detective story," for instance, in China took the form of the gong'an, or "court case," in which the protagonist is not a private detective or police officer but the county magistrate, who is investigator, prosecutor, and judge. The magistrate solves a crime which has already been described to the reader, so that the suspense does not come not from discovering the criminal but from seeing how the magistrate solves the crime through clever stratagems. Among these magistrate-detectives were the historical Tang dynasty official Di Renjie, who inspired a series of Judge Dee stories, and the Song dynasty official, Bao Zheng the hero of a set of stories and operas.
Since Chinese popular religion considered the world of life after death to closely resemble this one, the gods were part of a great bureaucracy which had the same structure as the imperial bureaucracy. The process of justice was pictured as being much the same in both worlds. The Magistrates of Hell presided over a court in much the way that the county magistrate did and their offices closely resembled the earthly ones.
The short story "Execution of Mayor Yin" by Chen Ruoxi (in which "xianzhang" is translated as "Mayor") describes the career of Mayor Yin from the early 1950s through the Cultural Revolution and dramatizes the dilemma of an official who is caught between the necessity of serving both his superiors and his constituents.