Background: Urinary tract infection (UTI) is a common infection in women, and it is more likely to occur during pregnancy due to mechanical and hormonal changes in pregnant women. Urinary tract infections can cause many complications for both mother and fetus. Given the roles of health behavior in the prevention of urinary tract infections and the nature of the theory of planned behavior-based education in behavioral change, the present study aimed to determine the effect of the theory of planned behavior-based education in teaching the urinary tract infection prevention behavior in pregnant women.Methods: The present study was a randomized controlled trial in which 100 pregnant women, who visited the comprehensive health service centers of Zarinshahr City, were randomly divided into two groups, intervention and control, containing 50 individuals. The data collection tools were a urine test and a questionnaire designed based on the theory of planned behavior. Five education sessions were held based on the constructs of the theory of planned behavior. We analyzed the effect of education review and data using independent t-tests, Mann-Whitney test, chi-square test, and repeated measures ANOVA (analysis of variance) one and three months after the educational intervention.Results: After implementing the educational intervention, the mean scores of knowledge and constructs of the theory of planned behavior significantly increased in the intervention group over time (P <0.001), while the difference was not significant in the control group over time. After the educational intervention, the incidence of urinary tract infections was 4.3 % in the intervention group and 21.3% in the control group.Conclusion: Given the positive effect of education based on the theory of planned behavior in changing the pregnant mothers' behavior, the theory can be used as a suitable intervention framework for implementing the educational programs to prevent urinary tract infections.Trial registration: Name: Iranian Registry of Clinical Trials. Registration number: IRCT20170214032575N1. Registration date: 2019-12-12 [retrospectively registered].