In most cases, the town or city grew up around or alongside the castle (for example in Halle, Brunswick and Prague), or the castle was built in order to reinforce the defences within or as part of the line of fortification ringing the settlement as, for example, at Erfurt.
Creighton draws a distinction between the 'urban castle', where the castle is built in or onto an existing town, and the 'castle borough', "where a primary castle attracts a secondary borough or the two are planned together," although he acknowledges that the division between the two is not always clear-cut.
The urban castle was also be used as an instrument of power, for example by William the Conqueror in Norman England, or by territorial lords in the Holy Roman Empire when towns in the late Middle Ages were increasingly striving for their independence. In such cases the urban castle was integrated into a strategically favourable point in the city wall so that the lord could enter the castle from the fields outside unhindered by the citizens and, through another gateway in the castle walls facing the city, could leave the castle and enter the city.
There are examples of urban castles in: