Purpose: To provide a tool for Monte Carlo simulations of dynamic beam delivery in the highly relevant situations where the full linac model is unavailable (such as is currently the case of the TrueBeam linac), which also includes the capability of reading and scoring 4D phase spaces. Methods: We have redesigned DOSXYZnrc source 20 to enable it to dynamically load a BEAMnrc shared library at run time and preserve synchronization between dynamic linac components and the beam motion in the patient geometry, even when starting from a phase space. We have enabled BEAMnrc and DOSXYZnrc to use the actual z coordinate of each particle, when reading a 3D IAEA phase space. Moreover, these codes can now read and output 4D phase spaces by reading/scoring the MU index of each particle. These 4D phase spaces can be used for further synchronization. Results: The updated source 20 has been validated, using film and ion chamber measurements (typically, differences around 1%), and comparisons with a commercial treatment planning system (3D gamma pass rates over 97% for a 3%‐3 mm criterion), for a variety of interesting clinical applications, including jaw‐tracking, non‐coplanar, and multiple‐arc VMAT, for both standard and flattening filter free (FFF) photon beams, starting from curved or general 4D IAEA phase space files. Conclusion: It is now possible to use source 20 for Monte Carlo simulations of TrueBeam and other modern radiotherapy technologies, starting from phase spaces (including curved or, more generally, 4D IAEA phase spaces). The simulations are performed in a single run, continuously, regardless of the complexity of the beam delivery. The new features have been extensively tested in clinical applications, with excellent results. The new 4D phase space capability could prove invaluable in other applications, such as in vivo portal dosimetry or adaptive planning. This work was supported, in part, by research grants provided by British Columbia Cancer Agency and Varian Medical Systems.