Klebsiella pneumoniae is a common cause of antimicrobial-resistant opportunistic infections in hospitalized patients. The species is naturally resistant to penicillins, and members of the population often carry acquired resistance to multiple antimicrobials. However, knowledge of K. pneumoniae ecology, population structure or pathogenicity is relatively limited. Over the past decade, K. pneumoniae has emerged as a major clinical and public health threat owing to increasing prevalence of healthcare-associated infections caused by multidrug-resistant strains producing extended-spectrum β-lactamases and/or carbapenemases. A parallel phenomenon of severe community-acquired infections caused by ‘hypervirulent’ K. pneumoniae has also emerged, associated with strains expressing acquired virulence factors. These distinct clinical concerns have stimulated renewed interest in K. pneumoniae research and particularly the application of genomics. In this Review, we discuss how genomics approaches have advanced our understanding of K. pneumoniae taxonomy, ecology and evolution as well as the diversity and distribution of clinically relevant determinants of pathogenicity and antimicrobial resistance. A deeper understanding of K. pneumoniae population structure and diversity will be important for the proper design and interpretation of experimental studies, for interpreting clinical and public health surveillance data and for the design and implementation of novel control strategies against this important pathogen.