A moat is a deep, broad ditch, either dry or filled with water, that is dug and surrounds a castle, fortification, building, or town, historically to provide it with a preliminary line of defence. In some places moats evolved into more extensive water defences, including natural or artificial lakes, dams and sluices. In older fortifications, such as hillforts, they are usually referred to simply as ditches, although the function is similar. In later periods, moats or water defences may be largely ornamental. They could also act as a sewer.
Some of the earliest evidence of moats has been uncovered around ancient Egyptian castles. One example is at Buhen, a castle excavated in Nubia. Other evidence of ancient moats is found in the ruins of Babylon, and in reliefs from ancient Egypt, Assyria, and other cultures in the region.
Evidence of early moats around settlements has been discovered in many archaeological sites throughout Southeast Asia,