It has been argued that skeletal Mg/Ca ratio in echinoderms is mostly governed by Mg2+ and Ca2+ concentrations in the ambient seawater. Accordingly, well-preserved fossil echinoderms were used to reconstruct Phanerozoic seawater Mg2+/Ca2+ ratio. However, Mg/Ca ratio in echinoderm skeleton can be affected by a number of environmental and physiological factors, the effects of which are still poorly understood. Notably, experimental data supporting the applicability of echinoderms in paleoenvironmental reconstructions remain limited. Here, we investigated the effect of ambient Mg2+/Ca2+ seawater ratio and diet on skeletal Mg/Ca ratio and growth rate in two echinoid species (Psammechinus miliaris and Prionocidaris baculosa). Sea urchins were tagged with manganese and then cultured in different Mg2+/Ca2+ conditions to simulate fluctuations in the Mg2+/Ca2+ seawater ratios in the Phanerozoic. Simultaneously, they were fed on a diet containing different amounts of magnesium. Our results show that the skeletal Mg/Ca ratio in both species varied not only between ossicle types but also between different types of stereom within a single ossicle. Importantly, the skeletal Mg/Ca ratio in both species decreased proportionally with decreasing seawater Mg2+/Ca2+ ratio. However, sea urchins feeding on Mg-enriched diet produced a skeleton with a higher Mg/Ca ratio. We also found that although incubation in lower ambient Mg2+/Ca2+ ratio did not affect echinoid respiration rates, it led to a decrease or inhibition of their growth. Overall, these results demonstrate that although skeletal Mg/Ca ratios in echinoderms can be largely determined by seawater chemistry, the type of diet may also influence skeletal geochemistry, which imposes constraints on the application of fossil echinoderms as a reliable proxy. The accuracy of paleoseawater Mg2+/Ca2+ calculations is further limited by the fact that Mg partition coefficients vary significantly at different scales (between species, specimens feeding on different types of food, different ossicle types, and stereom types within a single ossicle).