The effects of vacancies on mechanical properties of the transition metal c
arbides and nitrides are studied using the ab initio pseudopotential approa
ch. Calculated shear elastic stiffness and electronic structures show that
the vacancy produces entirely different effects on the mechanical strength
of groups IVb nitrides and Vb carbides. It is found that the occupation of
shear-unstable metallic dd bonding states changes essentially in an opposit
e way for the carbides and nitrides in the presence of vacancies, resulting
in different responses to sheer stress. Our study provides an atomistic un
derstanding of the anomaly in hardness for these substoichiometric material
s.