A Monte Carlo program for the simulation of electromagnetic cascades initiated by high-energy photons and electrons interacting with extragalactic background light (EBL) is presented. Pair production and inverse Compton scattering on EBL photons as well as synchrotron losses and deflections of the charged component in extragalactic magnetic fields (EGMF) are included in the simulation. Weighted sampling of the cascade development is applied to reduce the number of secondary particles and to speed up computations. As final result, the simulation procedure provides the energy, the observation angle, and the time delay of secondary cascade particles at the present epoch. Possible applications are the study of TeV blazars and the influence of the EGMF on their spectra or the calculation of the contribution from ultrahigh energy cosmic rays or dark matter to the diffuse extragalactic gamma-ray background. As an illustration, we present results for deflections and time-delays relevant for the derivation of limits on the EGMF.