CaP coatings were hydrothermally deposited on the AZ31 magnesium alloy in rection mixture containing ammonium or potassium ions. CaP coatings were deposited on AZ31 alloy in reaction mixture at pH 5 and 7 with and without EDTA chelating agent. It was found that the ammonium ions present have a negative effect on the quality of the CaP coating deposited from mixture at pH 7 and their presence at neutral environment results in the formation of structural defects in the coatings. At the same time, the presence of ammonium ions suppresses hydrolysis and crystallization of OCP and HAp. However, pH and the presence of EDTA have a more pronounced effect on the structure and phase composition. The coatings deposited in the reaction mixture, containing potassium-based precursors and EDTA, at pH 7 showed the best thermal stability due to the majority of HAp phase. The uniform CaP coating deposited in the reaction mixture containing EDTA and K+ ions at pH 7 also achieved the best corrosion properties due to the absence of structural defects and dense structure.