We use 3D radiative MHD simulations of the upper turbulent convection layer for investigation of physical mechanisms of formation of magnetic structures on the Sun. The simulations include all essential physical processes, and are based of the LES (Large-Eddy Simulations) approach for describing the sub-grid scale turbulence. The simulation domain covers the top layer of the convection zone and the lower atmosphere. The results reveal a process of spontaneous formation of stable magnetic structures from an initially weak vertical magnetic field, uniformly distributed in the simulation domain. The process starts concentration of magnetic patches at the boundaries of granular cells, which are subsequently merged together into a stable large-scale structure by converging downdrafts below the surface. The resulting structure represents a compact concentration of strong magnetic field, reaching 6 kG in the interior. It has a cluster-like internal structurization, and is maintained by strong downdrafts extending into the deep layers.