A moat is a deep, broad ditch, either dry or filled with water, that surrounds a castle, other 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 later periods the moat or water defences may be largely ornamental.
Not to be confused with motte - an earthen mound with a flat top and with the bailey form a motte-and-bailey castle, however the term is derived from the same Old French word at motte, indicating that the two features were closely linked.