Abstract Background Cyberloafing exists extensively in online learning and impairs learning, yet little is known about how course‐related factors affect it. The community of inquiry framework maintains that learning is affected by teaching presence, according to which, we assume that teaching presence impacts cyberloafing, which is mediated by social presence, cognitive presence, and lack of attention, and moderated by normative influence. Aims This study examined the effect of teaching presence on cyberloafing and its underlying mechanisms – the mediating roles of social presence, cognitive presence and lack of attention, and the moderating roles of normative influence. Sample Participants were 814 university students who were taking video‐centric asynchronous online courses. Methods Self‐report instruments were adopted, and data were analysed using structural equation modelling. Results Teaching presence was negatively associated with cyberloafing. Social presence (positively), cognitive presence (negatively), and lack of attention (negatively) mediated the relation, respectively. Social presence, cognitive presence and lack of attention were also serial mediators of the association (i.e., teaching presence → social presence → cognitive presence → cyberloafing; teaching presence → cognitive presence → lack of attention → cyberloafing; teaching presence → social presence → cognitive presence → lack of attention → cyberloafing), and these sequential mediating effects were negative. Moreover, normative influence could aggravate the negative effect of cognitive presence on lack of attention, the positive effect of social presence on cyberloafing, and the positive effect of lack of attention on cyberloafing. Conclusions Theoretical and practical implications of the findings for learning and teaching are discussed.