An optimal composition for magnesium liquid membrane sensor based on the reaction of magnesium ions with the macro cyclic reagent 1,4,7-triazacyclononane-1,4,7-tris-methylene methylphosphinic acid. The characteristics slope (30.5 mV), the limit of detection (6.2 x 10-7 M), the coefficient of selectivity toward some metal ions, response time (15 s), lifetime (180 days),the effect of pH on the sensor potential and the basic analytical parameters were studied. The sensor was used to estimate the concentration magnesium ions concentration in pharmaceutical preparations. The obtained results by the developed sensor were statistically analyzed and compared with those of other different reported methods.