Agpaitic rocks form the major part of the Ilímaussaq intrusion in S Greenland. The agpaitic magma developed as the narrow top zone in a large stratified basalt-syenite magma chamber at depth. The extreme composition of the agpaitic magma is related to an unusually high crustal position of the cupola. After emplacement, the agpaitic magma developed in an essentially closed system. The magma chamber was shallow and the volatile-rich alkaline magma was light and fluid. Heat loss was mainly through the roof, and the earliest agpaitic rocks crystallized successively downwards from the roof. The magma was probably well mixed in the early stage, but there is evidence for accumulation of residual components in a layer below the roof. This accumulation of low-melting components eventually suppressed the downwards crystallization of the roof rocks. The exposed floor rocks, kakortokites and lujavrites, are younger than the roof rocks, and at this stage the magma had probably developed repeated layering. The layering in the kakortokites, with density-graded units 7 m thick repeated continuously over the whole exposed floor, can be simply explained if they formed from a layered magma by successive upwards crystallization of individual layers. The magma at this stage was nearly volatile saturated, and each layer crystallized in response to the upward loss of a certain amount of volatiles. The lujavrites conformably overlie the kakortokites and formed after a roof collapse which caused the rate of heat loss from the remaining magma to increase. The upward crystallization became faster than the upward transport of residual components, and the successive lujavrites contain more and more of these components which finally gave rise to potentially economic concentrations of U, Be and other rare elements. Finally, a hydrothermal phase was lost from the system.