The production of D* and D mesons in inelastic scattering of 160 GeV/c muons off a 6LiD target has been investigated with the COMPASS spectrometer at CERN for 0. 003 (GeV/c)2<Q2<10 (GeV/c)2 and 3×10-5<xBj<0. 1. The study is based on 8100 events where a D0 or D0 is detected subsequently to a D*+ or D*- decay, and on 34000 events, where only a D0 or D0 is detected. Kinematic distributions of D*, D and K2 * (1430) are given as a function of their energy E, transverse momentum pT, energy fraction z, and of the virtual photon variables ν, Q2 and xBj. Semi-inclusive differential D* production cross-sections are compared with theoretical predictions for D* production via photon-gluon fusion into open charm. The total observed production cross-section for D*± mesons with laboratory energies between 22 and 86 GeV is (1. 9±0. 4) nb. Significant cross-section asymmetries are observed between D*+ and D*- production for ν<40 GeV and z>0. 6.