Necrotizing enterocolitis (NEC) afflicts approximately 10% of extremely preterm infants with high fatality. Inappropriate bacterial colonization with Enterobacteriaceae is implicated, but no specific pathogen has been identified. We identify uropathogenic E. coli (UPEC) colonization as a significant risk factor for the development of NEC and subsequent mortality. We describe a large-scale deep shotgun metagenomic sequence analysis of the early intestinal microbiome of 144 preterm and 22 term infants. Using a pan-genomic approach to functionally subtype the E. coli, we identify genes associated with NEC and mortality that indicate colonization by UPEC. Metagenomic multilocus sequence typing analysis further defined NEC-associated strains as sequence types often associated with urinary tract infections, including ST69, ST73, ST95, ST127, ST131, and ST144. Although other factors associated with prematurity may also contribute, this report suggests a link between UPEC and NEC and indicates that further attention to these sequence types as potential causal agents is needed.