The competition between two regimes of the nucleation of superconductivity is investigated experimentally and theoretically in a mesoscopic disk-shaped superconductor/ferromagnet hybrid. By changing the magnetic state of a multilayered Co/Pt disk one can reversibly affect the magnetic-field dependence of the critical temperature T c ͑H͒ of an Al layer. We demonstrate that an enhancement of the magnetic field near the edge of the out-of-plane magnetized disk either stimulates the nucleation of superconductivity at the disk perimeter due to the field compensation effect or prevents it due to edge magnetic barrier ͑for relatively low ͉H͉ values͒. As a consequence, the presence of such magnetic-field pattern makes it possible to eliminate boundary effects for mesoscopic superconducting samples. Switching from one nucleation regime to another while sweeping H leads to an abrupt change of the slope of the T c ͑H͒ envelope. The coexistence of superconductivity and magnetic order has been intensively studied for several decades ͑see review 1 and references therein͒. Recent achievements in nanotechnology make it possible to prepare hybrid superconductor/ ferromagnet ͑S/F͒ structures and study experimentally different aspects of the nontrivial interaction between the S and F components. In the case of spatially separated S and F subsystems, when the direct exchange of electrons at the interface between the two materials becomes suppressed, the interaction is dominated by the slow decaying magnetic fields b͑r͒ induced by the ferromagnet. In particular, the inhomogeneous b͑r͒ field generated by magnetic domains in the F layer affects strongly the nucleation of the superconductivity in the S layer and leads to exotic dependences of the critical temperature T c on an external magnetic field H. 2-9 Indeed, the presence of inhomogeneous fields results in the appearance of places where the transverse component of the total magnetic field ͉b z ͑r͒ + H͉ reaches a local minimum and thus the nucleation of localized superconductivity in thin superconducting films will be promoted due to the field compensation effect.The sample's imperfections or boundaries also stimulate the appearance of localized superconductivity in real samples. 10 As a result, a competition between different regimes of the order-parameter ͑OP͒ nucleation leads to additional modifications of the phase boundary T c ͑H͒. The OP nucleation in S/F hybrids with different competing confinements was recently studied theoretically in Refs. 3-6, 8, and 9. For example, for a generic S/F hybrid, consisting of a mesoscopic superconducting disk and a small magnetic particle, theory predicts two well-defined regimes: superconductivity can nucleate either near the disk center ͑under the magnetic particle͒ or at the disk edge. Switching between these regimes induced by varying the external field has been predicted to result in an abrupt change of the slope of T c ͑H͒. 5 These important theoretical findings have not yet been verified experimentally.In this work we check experimen...