Here is a link explaining the history of Bavaria:
Stadtrecht, Stadtverfassung and Stadtverwaltung (city rights, privileges and administration)
Cities throughout Germany received over the centuries privileges granted by sovereign lords. One such city was Rain in Bavaria. The city’s rights, privileges and administration stands as a model for most other cities in medieval times.
The city administration existed of a mayor (Bürgermeister) and his council (Ratsherren) as well as a selection of other citizens. These men were elected and served as an honorary team for a limited amount of time. At their side was the Stadtschreiber, the scribe, who had to be a trained lawyer and who received a salary for his services. The mayor had the last say in pronouncing verdicts, his council helped him find the verdict. The Rat was also responsible for controls over weights and measures, to establish price ranges for bread, meat and wine and other commodities. They determined the punishment when such rules were not observed. They controlled the interests of craftsmen. Sometimes the punishments the “Rat” inflicted seemed harsh or strange. For instance, “evil women” had the “Geige angeschlagen”, meaning they had to stand in a public place for hours displaying a note on their chest which told of their disgraceful deed.
The Rat ruled who and what amount of money someone should pay before he could become a citizen to their town. They issued marriage instructions. When someone married for the second time, he needed to settle with the children of the first marriage. The contents of some of the directions seem belittling to us, such as giving people the directions for a private festivity.
Typically, a city would receive next to the privileges of measure and weight, building rights, establish their own police force, prosecute minor offences and have the right to levy taxes. Minor offences were litigations and crimes not punishable by death. Murder, theft, rape, arson were punishable by higher authorities, the ducal judge. This man also was the notary public. The city had first jurisdiction only in the city, later on the lower jurisprudence was extended to the area surrounding the city (example: Stadtkreis Kiel, Amt Kiel).
The city of Rain later also received the so called “Stapelrecht“ which actually means market rights. They were able to make transient merchants stay in the city for a while, pile up their wares and offer them up for purchase as well as impound an "Ungeld" (excise). Later on the city was given a twice yearly market right and installed a bailiff to impound debts.
Important changes occurred for Bavarian cities at the beginning of the 19th century. After French examples the kingdom strove for centralized administration, therefore, the cities lost their privileges and self administrative measures.