The phase transitions,electronic structures and optical properties of Mg_2C were investigated using the first-principles plane-wave method within the pseudopotential and generalized gradient approximations. The calculated results demonstrate that Mg_2C undergoes two pressure-induced phase transitions: one is a first-order phase transition from the anti-fluorite structure to the anti-cotunnite structure at 20.09 GPa,and the other is a second-order phase transition from the anti-cotunnite structure to the Ni_2In-type structure at 260 GPa.Moreover,the electronic and optical properties of Mg_2C under pressure were discussed;they show that the band gaps become broader with the increase of the pressure.This is different from Mg_2Si,which has become metallic at high pressure.