We report the first nonadiabatic molecular dynamics study based on the exact factorization of the electron-nuclear wave function. Our approach (a coupled-trajectory mixed quantum-classical, CT-MQC, scheme) is based on the quantum-classical limit derived from systematic and controlled approximations to the full quantum-mechanical problem formulated in the exact-factorization framework. Its strength is the ability to correctly capture quantum (de)coherence effects in a trajectory-based approach to excited-state dynamics. We show this by benchmarking CT-MQC dynamics against a revised version of the popular fewest-switches surface-hopping scheme that is able to fix its well-documented overcoherence issue. The CT-MQC approach is successfully applied to investigation of the photochemistry (ring-opening) of oxirane in the gas phase, analyzing in detail the role of decoherence. This work represents a significant step forward in the establishment of the exact factorization as a powerful tool to study excited-state dynamics, not only for interpretation purposes but mainly for nonadiabatic ab initio molecular dynamics simulations.