Introduction: Gastric acidity plays an important role in the protection of infants against various pathogens from the environment. The histamine-2 receptor blockers (H2-blockers) are off-labeled drugs that are frequently prescribed in preterm neonates to prevent stress ulcers. The impact of the H2-blockers on the development of the necrotizing enterocolitis (NEC) in preterm infants is still controversial, particularly in the developing world. Materials and Methods: One hundred twenty-two preterm infants were enrolled in the study. The multivariate logistic regression model was used to identify potential postnatal risk factors associated with NEC. Results: Preterm infants (n = 51) with total NEC, medical NEC, and surgical NEC had the highest rate of receiving ranitidine compared with controls (n = 71) (39.2%, 19.6%, and 47.6%, p < 0.05). Logistic regression analysis revealed that ranitidine use and nosocomial infections were significantly associated with NEC development (odds ratios 1.55 and 3.3). Conclusions: We confirm that ranitidine administration was associated with an increased risk of NEC in preterm infants. H2-blockers use should be only administered in very strictly selected cases after careful consideration of the risk-benefit ratio.