The magnetic properties of Mn5Si3Cx and Mn5Ge3Cx films prepared by magnetron cosputtering or C+-ion implantation are studied. The carbon-doped films exhibit ferromagnetic properties with Curie temperatures T C well above room temperature and metallic conductivity, making them possible candidates for future magnetic semiconductor-based devices. In Mn5Si3Cx, the carbon gives rise to a lattice expansion and a concomitant change of the magnetic order from antiferromagnetic Mn5Si3 to ferromagnetic Mn5Si3C0.8 with T C = 350 K. Likewise, T C of ferromagnetic Mn5Ge3 is strongly enhanced in Mn5Ge3C0·8. However, in this case the lattice is slightly compressed by carbon. This demonstrates that the effect of carbon on the magnetic behaviour in these compounds is not simply due to a change of the various interatomic distances by carbon but also due to a modification of the electronic band structure.