- In this study we provide the first numerical demonstration of the effects of turbulence on the mean Lorentz force and the resulting formation of large-scale magnetic structures. Using three-dimensional direct numerical simulations (DNS) of forced turbulence we show that an imposed mean magnetic field leads to a decrease of the turbulent hydromagnetic pressure and tension. This phenomenon is quantified by determining the relevant functions that relate the sum of the turbulent Reynolds and Maxwell stresses with the Maxwell stress of the mean magnetic field. Using such a parameterization, we show by means of two-dimensional and three-dimensional mean-field numerical modelling that an isentropic density stratified layer becomes unstable in the presence of a uniform imposed magnetic field. This large-scale instability results in the formation of loop-like magnetic structures which are concentrated at the top of the stratified layer. In three dimensions these structures resemble the appearance of bipolar magnetic regions in the Sun. The results of DNS and mean-field numerical modelling are in good agreement with theoretical predictions. We discuss our model in the context of a distributed solar dynamo where active regions and sunspots might be rather shallow phenomena.