This paper presents an economic model of an epidemic in which susceptible individuals may engage in costly social distancing in order to avoid becoming infected. Infected individuals eventually recover and acquire immunity, thereby ceasing to be a source of infection to others. Under non-cooperative and forward-looking decision making, equilibrium social distancing arises endogenously around the peak of the epidemic, when disease prevalence reaches a critical threshold determined by preferences. Spontaneous, uncoordinated social distancing thus acts to flatten the curve of the epidemic by reducing peak prevalence. In equilibrium, social distancing stops once herd immunity sets in, but acts to extend the duration of the epidemic beyond the benchmark of a non-behavioral epidemiological model. Comparative statics with respect to the model parameters indicate that the curve becomes flatter (i) the more infectious the disease is and (ii) the more severe the health consequences of the disease are for the individuals