The disclosure relates to a wear element (23) for a slurry pump arrangeable in a pump housing, wherein at least a portion of the wear element (23) produces a magnetic field for attracting magnetic particles in a slurry processed by the slurry pump. The wear element comprises a magnet for producing the magnetic field, arranged such to generate formation of a protective wear layer on a surface of the wear element when used in a slurry pump. The disclosure further relates to a slurry pump (1) comprising a pump housing (2) and a wear element (23) arranged within the pump housing (2), wherein at least a portion of the wear element (23) produces a magnetic field for attracting magnetic particles present in a slurry processed by the slurry pump (1). The disclosure also relates to a method for producing a protective wear layer in a slurry pump comprising the steps of arranging a wear element in a housing of the slurry pump, wherein at least a portion of the wear element produces a magnetic field; and pumping a slurry comprising magnetic particles through the slurry pump, whereby magnetic particles of the slurry are attracted by the magnetic field, thereby creating the protective wear layer on the wear element.