When bullying occurs in school, most students are not only aware of it, but are also present and witness bullying. In the case of witnessing bullying, a bystander may recognize bullying as wrong, and feel responsible and motivated to intervene, but they may occasionally fail to actively intervene and defend a bullied peer for any reasons. The purpose of this study was to investigate how moral distress, conformity, collective efficacy and psychological safety in the class were related to bystander behaviors (assertive defender, comforting defender, sympathetic outsider, and indifferent outsider) in bullying. In addition to examining the pathways to bystander behaviors, we also tested the hypothesis that middle school students have different pathways from those of primary school students. One thousand one hundred and six Japanese primary school students (49.1% girls) and nine hundred and twenty middle school students (46.8% girls) participated in our questionnaire survey. T-test showed that compared with middle school students, primary school students significantly expressed more defending and remaining passively aside, higher moral distress, collective efficacy and psychological safety and less conformity. In order to examine how each variable is related to the occurrence of bystander behaviors, we converted the experience of bystander behaviors into a binary value, with "never" set to "0" and all other responses set to "1", and conducted a binomial logistic regression analysis by using experience of bystander behaviors as the criterion variable. Results showed that defender behaviors only among middle school students and outsider behaviors were positively predicted by conformity, and that indifferent outsider behavior was negatively predicted by collective efficacy. Moreover, the results of simple slope analysis for the significant effect of two-way interaction suggested that collective efficacy might regulate the effect of moral distress on defending behaviors among only middle school students. Implications of these findings are discussed.