Genetic studies in the tuberculosis mouse model have suggested that mycobacterial metal efflux systems, such as the P1B4‐ATPase CtpD, are important for pathogenesis. The specificity for substrate metals largely determines the function of these ATPases; however, various substrates have been reported for bacterial and plant P1B4‐ATPases leaving their function uncertain. Here we describe the functional role of the CtpD protein of Mycobacterium smegmatis. An M. smegmatis mutant strain lacking the ctpD gene was hypersensitive to Co2+ and Ni2+ and accumulated these metals in the cytoplasm. ctpD transcription was induced by both Co2+ and superoxide stress. Biochemical characterization of heterologously expressed, affinity‐purified CtpD showed that this ATPase is activated by Co2+, Ni2+ and to a lesser extend Zn2+ (20% of maximum activity). The protein was also able to bind one Co2+, Ni2+ or Zn2+ to its transmembrane transport site. These observations indicate that CtpD is important for Co2+ and Ni2+ homeostasis in M. smegmatis, and that M. tuberculosis CtpD orthologue could be involved in metal detoxification and resisting cellular oxidative stress by modulating the intracellular concentration of these metals.