A defensive wall is a fortification usually used to protect a city, town or other settlement from potential aggressors. The walls can range from simple palisades or earthworks to extensive military fortifications with towers, bastions and gates for access to the city. From ancient to modern times, they were used to enclose settlements. Generally, these are referred to as city walls or town walls, although there were also walls, such as the Great Wall of China, Walls of Benin, Hadrian's Wall, Anastasian Wall, and the Atlantic Wall, which extended far beyond the borders of a city and were used to enclose regions or mark territorial boundaries. In mountainous terrain, defensive walls such as letzis were used in combination with castles to seal valleys from potential attack. Beyond their defensive utility, many walls also had important symbolic functions - representing the status and independence of the communities they embraced.
Existing ancient walls are almost always masonry structures, although brick and timber-built variants are also known. Depending on the topography of the area surrounding the city or the settlement the wall is intended to protect, elements of the terrain such as rivers or coastlines may be incorporated in order to make the wall more effective.
Walls may only be crossed by entering the appropriate city gate and are often supplemented with towers. The practice of building these massive walls, though having its origins in prehistory, was refined during the rise of city-states, and energetic wall-building continued into the medieval period and beyond in certain parts of Europe.
Simpler defensive walls of earth or stone, thrown up around hillforts, ringworks, early castles and the like, tend to be referred to as ramparts or banks.
From very early history to modern times, walls have been a near necessity for every city. Uruk in ancient Sumer (Mesopotamia) is one of the world's oldest known walled cities. Before that, the proto-city of Jericho in the West Bank had a wall surrounding it as early as the 8th millennium BC.