We determine structural and electronic properties of NanMg clusters (n=6-9, 18), using the Car-Parrinello method. The low-energy isomers, which result from our dynamical simulated annealing search, can be described as substitutionally doped sodium clusters. The Mg impurity is never located at the center of the cluster, in contrast to the assumptions of spherical jellium models (SJMs) and of earlier ab initio calculations. Accordingly, the electronic configuration is found to be more complex than that predicted by SJMs. The experimentally observed disappearance of a magic number at n=8 on passing from NanZn and KnMg to NanMg is explained as a result of the difference in the low-energy structures. © 1992.