Mass vaccination campaigns have drastically reduced the burden of infectious diseases. Unfortunately, in recent years several infectious diseases have re-emerged. Pertussis poses a well-known example. Inspired by pertussis, we study, by means of an epidemic model, the population and evolutionary dynamics of a pathogen population under the pressure of vaccination. A distinction is made between infection in immunologically naive individuals (primary infection) and infection in individuals whose immune system has been primed by vaccination or infection (secondary infection). The results show that (i) vaccination with an imperfect vaccine may not succeed in reducing the infection pressure if the transmissibility of secondary infections is higher than that of primary infections; (ii) pathogen strains that are able to evade the immunity induced by vaccination can only spread if escape mutants incur no or only a modest fitness cost and (iii) the direction of evolution depends crucially on the distribution of the different types of susceptibles in the population. We discuss the implications of these results for the design and use of vaccines that provide temporary immunity.