- Context. In the presence of strong density stratification, turbulence can lead to the large-scale instability of a horizontal magnetic field if its strength is in a suitable range (around a few percent of the turbulent equipartition value). This instability is related to a suppression of the turbulent pressure so that the turbulent contribution to the mean magnetic pressure becomes negative. This results in the excitation of a negative effective magnetic pressure instability (NEMPI). This instability has so far only been studied for an imposed magnetic field. Aims: We want to know how NEMPI works when the mean magnetic field is generated self-consistently by an α2 dynamo, whether it is affected by global spherical geometry, and whether it can influence the properties of the dynamo itself. Methods: We adopt the mean-field approach, which has previously been shown to provide a realistic description of NEMPI in direct numerical simulations. We assume axisymmetry and solve the mean-field equations with the Pencil Code for an adiabatic stratification at a total density contrast in the radial direction of ≈4 orders of magnitude. Results: NEMPI is found to work when the dynamo-generated field is about 4% of the equipartition value, which is achieved through strong α quenching. This instability is excited in the top 5% of the outer radius, provided the density contrast across this top layer is at least 10. NEMPI is found to occur at lower latitudes when the mean magnetic field is stronger. For weaker fields, NEMPI can make the dynamo oscillatory with poleward migration. Conclusions: NEMPI is a viable mechanism for producing magnetic flux concentrations in a strongly stratified spherical shell in which a magnetic field is generated by a strongly quenched α effect dynamo.