Soil fauna takes an active part in accelerating turnover of nutrients in terrestrial ecosystems. Anaerobic ammonium oxidation (anammox) has been widely characterized, however, whether anammox is active in earthworm gut and the effect of earthworm on anammox in soil remain unknown. In this study, the activity, abundance and community of anammox bacteria in earthworm guts and soils from microcosms were determined using a 15N-tracing technique, quantitative PCR, and anammox bacterial 16S rRNA gene amplicon sequencing. Results showed that anammox rates in guts ranged between 5.81 and 14.19 nmol N g-1 dw gut content h-1, which were significantly (P < 0.01) higher than that in their surrounding soils during 30 day incubation. On the contrary, abundances of hzsB genes encoding subunit B hydrazine synthase in guts were significantly (P < 0.05) lower than those in their surrounding soils. Anammox rates, denitrification N2 production rates and hzsB genes in soils with earthworms were significantly (P < 0.05) lower than those in control soils. Anammox bacterial compositions differed significantly (P < 0.05) between gut and soil, and earthworm altered anammox bacterial communities in soils. Brocadia, Kuenenia and abundant unclassified anammox bacteria were detected in collected soils and gut contents, in which Brocadia was only detected in guts. These results suggested that microbes in earthworm gut increase, but present of earthworm reduces anammox and denitrification associated N loss by altering the anammox bacterial community compositions in soils.