The introduction of artificial intelligence (AI) as a subject in K-12 education is a new and important global strategic initiative, but there is a serious lack of studies in relation to this initiative that address inclusion and diversity of education. Self-determination theory (SDT) can explain student engagement from the needs satisfaction perspective. Therefore, this project aimed to investigate how SDT-based needs support by teachers and student attributes (gender and achievement level) affect AI learning at secondary school level. It adopted a two-study design, with each study using a 2 × 2 between-subjects factorial design with student needs support from teachers as one factor and one of the student attributes as the other: gender in Study 1 and achievement level in Study 2. In both studies, there were two groups – SDT-based (teacher needs support) and control (without). The analyses revealed that in the SDT-based program, (1) the students had a more positive perception of AI learning and felt that their needs were satisfied, and (2) there were non-significant differences in AI learning between boys and girls and between high and low achievers. The findings suggest that a focus on needs satisfaction could engage boys and girls, and high and low achievers in AI learning. As they become more engaged, they are likely to gain more confidence, feel that the content is more relevant, and become intrinsically motivated to pursue further AI learning. • A high-quality Artificial Intelligence (AI) school education should be designed in a fair and inclusive manner. • AI K–12 education is a new global strategic initiative, but lack of relevant studies. • This study used self-determination theory to develop a teacher need support as intervention. • The support catered to the needs of students with different genders and achievement levels. • All the students gained more confidence and became intrinsically motivated to pursue further AI learning.