Having applied the methods of comprehensive melt inclusion studies, we elucidated the formation conditions for one of the largest apatite deposits in the Maimecha–Kotui province, located in the exocontact zone of the Magan alkaline ultramafic carbonatite massif, in apoquartzite fenite-aegirinites. We examined the most P-enriched exocontact nepheline-containing aegirinites and ijolite veins in them. In veined ijiolite, primary silicate–salt melt inclusions in nepheline and syngenetic primary silicate, alkali sulfate–carbonate, and carbonate melt inclusions in apatite were found. Primary alkali sulfate–carbonate melt inclusions were also identified in apatite from exocontact nepheline-containing aegirinites. Detailed analysis of the inclusions showed that nepheline of the apatite-containing ijolite veins crystallized at 1100–1120 °C from homogeneous nephelinite melt, which was enriched in SO3, Cl, CO2, and H2O and locally contaminated with quartz sandstones and quartzites. At lower temperatures (either at the final stages of nepheline crystallization or at the early stages of apatite formation), the melt was already heterogeneous (probably, because of immiscibility) and consisted of more Si-saturated, alkali sulfate–carbonate, and carbonate fractions. Apatite crystallized mainly from separated alkali sulfate–carbonate melts: at 1080–980 °C in veined ijolites and at 940–760 °C in aegirinites. Alkali sulfate–carbonate melts in veined ijolites were enriched in SO3 but depleted in P as compared with those in aegirinites. At the final stage, apatite crystallized from P-poor carbonate melts.