The influence of lattice mismatch on the electrical and structural properties of HgCdTe epilayers grown on CdZnTe substrates has been investigated. A slight lattice mismatch of the order of less than ±0.1% between the epilayer and the substrate brings about a conductivity-type conversion of HgCdTe layers, which is related to the presence of misfit dislocations. It is considered that the conductivity-type conversion is caused by diffusion of impurities from the substrate to the epilayer due to the high interface dislocation density. This work emphasizes the importance of minimizing the interactions between the epilayer and its substrate by the precise lattice-matching.