Simulating SEM images is important in order to optimize SEM subsystems and the setup of the SEM for specific tasks, such as new devices and fabrication methods, as well as to complete simulation flows in lithography and nanofabrication. Monte Carlo simulators have been used for these purposes, but their disadvantage is the low speed of simulation. A fast analytic simulator of SEM images, ASEM, is presented in this paper, which takes into account the most important factors in SEM: electron scattering in 3D samples composed of various materials, electrical fields, the properties and geometry of detectors, and charging. This allows for a simulation accuracy approaching that of Monte Carlo, while the simulation time is on the scale of one minute. Examples of simulations and their comparison to actual experiments are presented with various detectors, samples, electrical fields and charging, including the contrast reversal effect due to charging. Simulations of SEM images using resist profiles exported from a lithography simulator are also presented.