Introduction: The prevalence of acquired immune deficiency syndrome (AIDS) is dramatically expanding in the world and the only way to deal with it is through health education. This study sought to determine the effect of educational intervention based on the theory of planned behavior (TPB) on AIDS preventive behaviors in nursing and midwifery students. Material and methods: This was a quasi-experimental study conducted in 2016, and included 104 nursing and midwifery students from Guilan University of Medical Sciences. A questionnaire consisted of sections with demographic characteristics, awareness, behaviors, and constructs of the theory of planned behavior, and was provided to every participant. The questionnaire content validity rate was 0.8, content validity index was equal to 0.82, and Cronbach's a coefficient test was 0.9. After collecting data in both groups, educational intervention was conducted within the framework of the theory of planned behavior in the intervention group. Data was collected before the intervention and three months later and was analyzed with SPSS statistics version 21. Results: There was no significant difference between the two groups in terms of demographic variables (p > 0.05). Additionally, no significant differences were noted between the intervention and control groups before the educational intervention in terms of awareness, attitude, subjective norms, perceived behavioral control, behavioral intention, and preventive behaviors (p > 0.05). However, after the implementation of educational program, these variables significantly increased in the intervention group (p < 0.05). Conclusions: The TPB was effective in teaching students in the field of AIDS prevention skills. Therefore, it is recommended to use the theory of planned behavior for human immunodeficiency virus prevention behaviors.