• The SHiP experiment is designed to search for very weakly interacting particles beyond the Standard Model which are produced in a 400 GeV/c proton beam dump at the CERN SPS. An essential task for the experiment is to keep the Standard Model background level to less than 0.1 event after $2\times 10^{20}$ protons on target. In the beam dump, around $10^{11}$ muons will be produced per second. The muon rate in the spectrometer has to be reduced by at least four orders of magnitude to avoid muon-induced combinatorial background. A novel active muon shield is used to magnetically deflect the muons out of the acceptance of the spectrometer. This paper describes the basic principle of such a shield, its optimization and its performance.