The phenomenon of antibiotic resistance is of practical importance and theoretical interest. As a foundation for further studies by simulation, experiment, and observation, we here develop a mathematical model for the dynamics of resistance among the bacteria resident in a population of hosts. The model incorporates the effects of natural selection within untreated hosts, colonization by bacteria from the environment, and the rapid increase of resistance in hosts who receive antibiotics. We derive explicit formulas for the distribution of resistance among hosts and for the rise or fall of resistance when the frequency of treatment is changed.