The purpose of this study is to present a novel method for generating Monte Carlo 4D dose distributions in a single DOSXYZnrc simulation. During a standard simulation, individual energy deposition events are summed up to generate a 3D dose distribution and their associated temporal information is discarded. This means that in order to determine dose distributions as a function of time, separate simulations would have to be run for each interval of interest. Consequently, it has not been clinically feasible until now to routinely perform Monte Carlo simulations of dose rate, time-resolved dose accumulation, or electronic portal imaging devices (EPID) cine-mode images for volumetric modulated arc therapy (VMAT) plans. To overcome this limitation, we modified DOSXYZnrc and defined new input and output variables that allow a time-like parameter associated with each particle history to be binned in a user-defined manner. Under the new code version, computation times are the same as for a standard simulation, and the time-integrated 4D dose is identical to the standard 3D dose. We present a comparison of scintillator measurements and Monte Carlo simulations for dose rate during a VMAT beam delivery, a study of dose rate in a VMAT total body irradiation plan, and simulations of transit (through-patient) EPID cine-mode images.