We use large-scale first-principles molecular dynamics simulations to find possible ways to make magnesium dication conductors based on Mg(BH 4)2. The Mg atoms are confined in a tetrahedral cage of BH4 groups and coordinated by eight hydrogen atoms from these groups. These Mg atoms do not move outside the cage either in high- or low-temperature phases. After introducing larger-sized AlH-4 anions by substitution of 20% BH-4, the Mg atoms are able to move outside the cage with coordination from hydrogen atoms of BH-4 located outside the cage. Substitution by Cl- and I- anions did not allow large Mg movements.