Secondary school students increasingly use generative artificial intelligence (GenAI), and evidence shows it can either support or weaken their self-regulated learning (SRL). This study examined whether teacher metacognitive scaffolding (TMS) and AI literacy (AIL) are related to SRL through productive cognitive offloading (PCO) and substitutive cognitive offloading (SCO), and whether peer collaborative AI use (PCAU) strengthens the link between scaffolding and productive offloading. We conducted a cross-sectional survey of 327 students from 24 classes in eight Indonesian madrasah aliyah (Islamic senior high schools) selected through stratified multistage cluster sampling. We analysed the data using partial least squares structural equation modelling with 10,000 bootstrap subsamples. The measurement model met the reliability and validity criteria. TMS was positively related to PCO (β = 0.378) and negatively related to SCO (β = −0.351), and AIL showed the same pattern with smaller coefficients. PCO was positively related to SRL (β = 0.291), whereas SCO was negatively related to it (β = −0.266). Both forms of offloading partially mediated the relationships of TMS and AIL with SRL. PCAU strengthened the TMS–PCO path (β = 0.257), and scaffolding was not significantly related to productive offloading when peer collaboration was low. The model explained 45.8% of the variance in SRL. The findings indicate that teacher guidance is associated with SRL both directly and, for nearly half of its total effect, through the way students offload their thinking to GenAI, particularly when students verify AI outputs together.