In spite of many years of research, the physical phenomena leading to the evolution of compacted graphite (CG) during solidification is still not fully understood. In particular, it is unknown how highly branched CG aggregates form and evolve in the semi-solid, and how local microstructural variations at micrometer length scale affect this growth process. We present here the first time-resolved synchrotron tomography combined with a bespoke high-temperature environmental cell that allows direct observation of the evolution of CG and relates this dynamic process to the local surrounding microstructures in a cast iron sample during repeated melting and solidification. Distinct processes are identified for the formation of CG involving the nucleation, growth, development of branches and interconnection of graphite particles, ultimately evolving into highly branched graphite aggregates with large sizes and low sphericities. CG is found to nucleate with a spheroidal or a plate-like shape, developing branches induced by high carbon concentration, e.g. thin melt channels. Additionally, CG grows much faster than spheroidal graphite during subsequent cooling in solid state. The direct visualization of the dynamic solidification process provides unprecedented new insights into formation mechanisms of CG and correlating factors such as local microstructural variations, and guides the development of CG iron solidification models.