The host launches an antimicrobial defense program upon infection. A long-held belief is that pathogens prevent host recognition by remodeling their surface in response to different host microenvironments. Yet direct evidence that this happens in vivo is lacking. Here we report that the pathogen Klebsiella pneumoniae modifies one of its surface molecules, the lipopolysaccharide, in the lungs of mice to evade immune surveillance. These in vivo-induced changes are lost in bacteria grown after isolation from the tissues. These lipopolysaccharide modifications contribute to survival in vivo and mediate resistance to colistin, one of the last options to treat multidrug-resistant Klebsiella. This work opens the possibility of designing novel therapeutics targeting the enzymes responsible for the in vivo lipid A pattern.