Recent progress in nanotechnology has stimulated interest in mesoscopic superconductors as components for quantum computing and cryoelectronics. The critical parameters for superconductivity (current and field) of a mesoscopic sample are determined by the pattern of vortices in it, which in turn is controlled by the symmetry imposed by the shape of the sample (see ref. 1 and references therein). Hitherto it has been unclear what happens when the number of vortices is not consistent with the natural symmetry. Here we show that additional vortex-antivortex pairs nucleate spontaneously so as to preserve the symmetry of the sample. For example, in a square with three vortices, the spontaneously generated pair, along with the original three vortices, distribute themselves so that the four vortices sit in the four corners, with the antivortex in the centre. The measured superconducting phase boundary (of superconducting transition temperature T-c versus magnetic field strength) is in very good agreement with the calculations, giving direct experimental evidence for these symmetry-induced vortex-antivortex pairs. Vortex entry into the sample is also changed: vortices enter a square in fours, with antivortices generated to preserve the imposed vorticity. The symmetry-induced nucleation of antivortices is not restricted to superconductors, but should also apply to symmetrically confined superfluids and Bose-Einstein condensates.