We develop a general approach to the nonequilibrium dynamics of quantum-impurity systems for arbitrary coupling strength. The numerical renormalization group is used to generate a complete basis set necessary for the correct description of the time evolution. We benchmark our method with the exact analytical solution for the resonant-level model. As a first application, we investigate the equilibration of an ultrasmall quantum dot subject to a sudden change of gate voltage and external magnetic field. Two distinct relaxation times are identified for the spin and charge dynamics.