  We present a radiative magnetohydrodynamics simulation of the formation of an
Active Region on the solar surface. The simulation models the rise of a buoyant
magnetic flux bundle from a depth of 7.5 Mm in the convection zone up into the
solar photosphere. The rise of the magnetic plasma in the convection zone is
accompanied by predominantly horizontal expansion. Such an expansion leads to a
scaling relation between the plasma density and the magnetic field strength
such that $B\propto\varrho^{1/2}$. The emergence of magnetic flux into the
photosphere appears as a complex magnetic pattern, which results from the
interaction of the rising magnetic field with the turbulent convective flows.
Small-scale magnetic elements at the surface first appear, followed by their
gradual coalescence into larger magnetic concentrations, which eventually
results in the formation of a pair of opposite polarity spots. Although the
mean flow pattern in the vicinity of the developing spots is directed radially
outward, correlations between the magnetic field and velocity field
fluctuations allow the spots to accumulate flux. Such correlations result from
the Lorentz-force driven, counter-streaming motion of opposite-polarity
fragments. The formation of the simulated Active Region is accompanied by
transient light bridges between umbrae and umbral dots. Together with recent
sunspot modeling, this work highlights the common magnetoconvective origin of
umbral dots, light bridges and penumbral filaments.
