Abstract Background Retinopathy of prematurity (ROP), is a preventable leading cause of blindness in infants and is a condition in which the immature retina experiences abnormal blood vessel growth. The development of ROP is multifactorial; nevertheless, the risk factors are controversial. This study aimed to identify risk factors of time to development of ROP in Iran. Methods This historical cohort study utilized data from the hospital records of all newborns referred to the ROP department of Farabi Hospital (from 2017 to 2021) and the NICU records of infants referred from Mahdieh Hospital to Farabi Hospital. Preterm infants with birth weight (BW) ≤ 2000 g or gestational age (GA) 2000 g or GA ≥ 34 wk. The outcome variable was the time to development of ROP (in weeks). Random survival forest was used to analyze the data. Results A total of 338 cases, including 676 eyes, were evaluated. The mean GA and BW of the study group were 31.59 ± 2.39 weeks and 1656.72 ± 453.80 g, respectively. According to the criteria of minimal depth and variable importance, the most significant predictors of the time to development of ROP were duration of ventilation, GA, duration of oxygen supplementation, bilirubin levels, duration of antibiotic administration, duration of Total Parenteral Nutrition (TPN), mother age, birth order, number of surfactant administration, and on time screening. The concordance index for predicting survival of the fitted model was 0.878. Conclusion Our findings indicated that the duration of ventilation, GA, duration of oxygen supplementation, bilirubin levels, duration of antibiotic administration, duration of TPN, mother age, birth order, number of surfactant administrations, and on time screening are potential risk factors of prognosis of ROP. The associations between identified risk factors were mostly nonlinear. Therefore, it is recommended to consider the nature of these relationships in managing treatment and designing early interventions.