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 sewerage.
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, including Noen U-Loke, Ban Non Khrua Chut, Ban Makham Thae and Ban Non Wat. The use of the moats could have been either for defensive or agriculture purposes.
Moats were excavated around castles and other fortifications as part of the defensive system as an obstacle immediately outside the walls. In suitable locations they might be filled with water. A moat made access to the walls difficult for siege weapons, such as siege towers and battering rams, which needed to be brought up against a wall to be effective. A water-filled moat made the practice of mining, digging tunnels under the castles in order to effect a collapse of the defences, very difficult as well. Segmented moats have one dry section and one section filled with water. Dry moats cut across the narrow part of a spur or peninsula are called neck ditches. Moats separating different elements of a castle, such as the inner and outer wards are cross ditches.