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 parallel to H parallel to 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.