Rapidly spinning magnetars can potentially form through the accretion induced collapse of a white dwarf or by neutron star (NS) mergers if the equation of state of the nuclear density matter is such that two low-mass NSs can form a massive NS rather than a black hole. In either case, the newborn magnetar is an attractive site for the production of ultrahigh-energy cosmic rays (particles with individual energies exceeding 10 eV; 18 UHECRs). The short-period spin and strong magnetic field are able to accelerate particles up to appropriate energies, and the composition of material on and around the magnetar may naturally explain recent inferences of heavy elements in UHECRs. We explore whether the small amount of natal debris surrounding these magnetars allows UHECRs to escape easily. We also investigate the impact on the UHECRs of the unique environment around the magnetar, which consists of a bubble of relativistic particles and magnetic field within the debris. The rates and energetics of UHECRs are consistent with such an origin, even though the rates of events that produce rapidly spinning magnetars remain very uncertain. The low ejecta mass also helps the high-energy neutrino background associated with this scenario to be below current IceCube constraints over most of the magnetar parameter space. A unique prediction is that UHECRs may be generated in old stellar environments without strong star formation, in contrast to what would be expected for other UHECR scenarios, such as active galactic nuclei or long gamma-ray bursts.