Mixing Mg with Ti leads to a hydride Mg(x)Ti(1-x)H2 with markedly improved (de)hydrogenation properties for x < 0.8, as compared to MgH2. Optically, thin films of Mg(x)Ti(1-x)H2 have a black appearance, which is remarkable for a hydride material. In this paper we study the structure and stability of Mg(x)Ti(1-x)H2, x= 0-1 by first-principles calculations at the level of density functional theory. We give evidence for a fluorite to rutile phase transition at a critical composition x(c)= 0.8-0.9, which correlates with the experimentally observed sharp decrease in (de)hydrogenation rates at this composition. The densities of states of Mg(x)Ti(1-x)H2 have a peak at the Fermi level, composed of Ti d states. Disorder in the positions of the Ti at...