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.