In this study the enzymatic activity of Mycoplasma agalactiae MAG_5040, a magnesium-dependent nuclease homologue to the staphylococcal SNase was characterized and its antigenicity during natural infections was established. A UGA corrected version of MAG_5040, lacking the region encoding the signal peptide, was expressed in Escherichia coli as a GST fusion protein. Recombinant GST-MAG_5040 exhibits nuclease activity similar to typical sugar-nonspecific endo- and exonucleases, with DNA as the preferred substrate and optimal activity in the presence of 20 mM MgCl2 at temperatures ranging from 37 to 45uC. According to in silico analyses, the position of the gene encoding MAG_5040 is consistently located upstream an ABC transporter, in most sequenced mycoplasmas belonging to the Mycoplasma hominis group. In M. agalactiae, MAG_5040 is transcribed in a polycistronic RNA together with the ABC transporter components and with MAG_5030, which is predicted to be a sugar solute binding protein by 3D modeling and homology search. In a natural model of sheep and goats infection, anti-MAG_5040 antibodies were detected up to 9 months post infection. Taking into account its enzymatic activity, MAG_5040 could play a key role in Mycoplasma agalactiae survival into the host, contributing to host pathogenicity. The identification of MAG_5040 opens new perspectives for the development of suitable tools for the control of contagious agalactia in small ruminants.