The overwhelming majority of rare-earth elements, tantalum, and lithium are found within pegmatite.  Ore genesis theories for these ores are wide and varied, but most involve metamorphism and igneous activity.  Lithium is present as spodumene or lepidolite within pegmatite.
Carbonatite intrusions are an important source of these elements. Ore minerals are essentially part of the unusual mineralogy of carbonatite.