The DArk Matter Particle Explorer (DAMPE), one of the four space-based scientific missions within the framework of the Strategic Pioneer Program on Space Science of the Chinese Academy of Sciences, was successfully launched on 2015 Dec. 17 from Jiuquan launch center. One of the most important scientific goals of DAMPE is to search for evidence of dark matter indirectly by measuring the spectrum of high energy cosmic-ray electrons. The neutron detector, one of the four sub-payloads of DAMPE, is designed to distinguish high energy electrons from hadron background by measuring the secondary neutrons produced in the shower. In this paper, a comprehensive introduction of the neutron detector is presented, including the design, calibration and performance. The analysis with simulated data and flight data indicates a powerful proton rejection capability of the neutron detector, which plays an essential role for TeV electron identification of DAMPE.