Ferromagnetic or antiferromagnetic spin ordering is governed by the exchange interaction, the strongest force in magnetism. Understanding spin dynamics in magnetic materials is an issue of crucial importance for progress in information processing and recording technology. Usually the dynamics are studied by observing the collective response of exchange-coupled spins, that is, spin resonances, after an external perturbation by a pulse of magnetic field, current or light. The periods of the corresponding resonances range from one nanosecond for ferromagnets down to one picosecond for antiferromagnets. However, virtually nothing is known about the behaviour of spins in a magnetic material after being excited on a timescale faster than that corresponding to the exchange interaction (10-100 fs), that is, in a non-adiabatic way. Here we use the element-specific technique X-ray magnetic circular dichroism to study spin reversal in GdFeCo that is optically excited on a timescale pertinent to the characteristic time of the exchange interaction between Gd and Fe spins. We unexpectedly find that the ultrafast spin reversal in this material, where spins are coupled antiferromagnetically, occurs by way of a transient ferromagnetic-like state. Following the optical excitation, the net magnetizations of the Gd and Fe sublattices rapidly collapse, switch their direction and rebuild their net magnetic moments at substantially different timescales; the net magnetic moment of the Gd sublattice is found to reverse within 1.5 picoseconds, which is substantially slower than the Fe reversal time of 300 femtoseconds. Consequently, a transient state characterized by a temporary parallel alignment of the net Gd and Fe moments emerges, despite their ground-state antiferromagnetic coupling. These surprising observations, supported by atomistic simulations, provide a concept for the possibility of manipulating magnetic order on the timescale of the exchange interaction.