GO:0010961: cellular magnesium ion homeostasis
Any process involved in the maintenance of an internal steady state of magnesium ions at the level of a cell.