Until the High Middle Ages the term "Burg" (German: castle) also meant a fortified town. New towns supplementing the former Roman cities often grew up out of marketplaces< near monasteries or castles.
City air did not make the people free, but made the area distinct: every such town was subject to its own master who secured his rights through the castle or through delegated "Burgmannen" from the lower aristocracy. This led to the establishment of municipal districts with special rights, preferably on the edge of a fortified settlement, often in a corner or on a hill. They sometimes had their own town gate as a nearby entrance. Control of a marketplace guaranteed revenues through the prerogative of coinage, because only the place's own currency was valid. The citizens also had to pay tariffs and ground rent.
A town was in fact a new kind of castle. It accommodated within its walls numerous men who were fit for military service; wealthy towns had well-stocked armouries and artillery, and owned their own territories. Big cities achieved the privileged status of "imperial immediacy", their upper class played a part in the courtly culture, and some wealthy merchants were even lifted into the aristocracy.