The evolution of antimicrobial resistance can be strongly affected by variations of antimicrobial concentration. Here, we study the impact of periodic alternations of absence and presence of antimicrobial on resistance evolution in a microbial population, using a stochastic model that includes variations of both population composition and size, and fully incorporates stochastic population extinctions. We show that fast alternations of presence and absence of antimicrobial are inefficient to eradicate the microbial population and strongly favor the establishment of resistance, unless the antimicrobial increases enough the death rate. We further demonstrate that if the period of alternations is longer than a threshold value, the microbial population goes extinct upon the first addition of antimicrobial, if it is not rescued by resistance. We express the probability that the population is eradicated upon the first addition of antimicrobial, assuming rare mutations. Rescue by resistance can happen either if resistant mutants preexist, or if they appear after antimicrobial is added to the environment. Importantly, the latter case is fully prevented by perfect biostatic antimicrobials that completely stop division of sensitive microorganisms. By contrast, we show that the parameter regime where treatment is efficient is larger for biocidal drugs than for biostatic drugs. This sheds light on the respective merits of different antimicrobial modes of action.Author summary Antimicrobials select for resistance, which threatens to make antimicrobials useless. Understanding the evolution of antimicrobial resistance is therefore of crucial importance. Under what circumstances are microbial populations eradicated by antimicrobials? Conversely, when are they rescued by resistance? We address these questions employing a stochastic model that incorporates variations of both population composition and size. We consider periodic alternations of absence and presence of antimicrobial, which may model a treatment. We find a threshold period above which the first phase with antimicrobial fully determines the fate of the population. Faster alternations strongly select for resistance, and are inefficient to eradicate the microbial population, unless the death rate induced by the treatment is large enough. For longer alternation periods, we calculate the probability that the microbial population gets eradicated. We further demonstrate the different merits of biostatic antimicrobials, which prevent sensitive microbes from dividing, and of biocidal ones, which kill sensitive microbes.