Gut microbiome plays an important role in adult human health and diseases. However, how nutritional factors shape the initial colonization of gut bacteria in infants, especially in preterm infants, is still not completely known. In this study, we compared the effects of feeding with mothers' own breast milk (MBM) and formula on the initial composition and gene expression of gut bacteria in moderate-late preterm infants. Fecal samples were collected from ten formula-fed and ten MBM healthy infants born between 32 and 37 weeks' gestation after they reached full-volume enteral feedings. Total DNAs were extracted from fecal samples for amplicon sequencing of 16S ribosomal RNA (rRNA) gene and total RNA with rRNA depletion for metatranscriptome RNA-Seq 16S rRNA gene amplicon sequencing results showed that the alpha-diversity was similar between the MBM-and formula-fed preterm infants, but the beta-diversity showed a significant difference in composition (p = 0.002). The most abundant taxa were Veillonella (18.4%) and Escherichia/Shigella (15.2%) in MBM infants, whereas the most abundant taxa of formula-fed infants were Streptococcus (18.6%) and Klebsiella (17.4%). The genera Propionibacterium, Streptococcus, and Finegoldia and order Clostridiales had significantly higher relative abundance in the MBM group than the formula group, whereas bacteria under family Enterobacteriaceae, genera Enterococcus and Veillonella, and class Bacilli were more abundant in the formula group. In general, microbiomes from both diet groups exhibited high functional levels of catalytic activity and metabolic processing when analyzed for gene ontology using a comparative metatranscriptome approach. Statistically, the microbial genes in the MBM group had an upregulation in expression related to glycine reductase, periplasmic acid stress response in Enterobacteria, acid resistance mechanisms, and L-fucose utilization. In contrast, the formula-fed group had upregulations in genes associated with methionine and valine degradation functions. Our data suggest that the nutritional source plays a role in shaping the moderate-late preterm gut microbiome as evidenced by the