Evidence indicates a link between autism spectrum disorder (ASD) and gender diversity, yet this intersection remains insufficiently understood. Here, we investigated whether (1) ASD affects gender-related cognition (i.e., mental processes of perceiving and interpreting one’s own gender self-concept), (2) autistic people have increased gender dysphoria and recall limited gender-typed behavior from childhood, and (3) transgender individuals have increased ASD-like traits and difficulties in mentalizing. A total of 106 non-autistic cisgender (51 birth-assigned female), 107 autistic cisgender (57 birth-assigned female), 78 non-autistic transgender (41 birth-assigned female), and 56 autistic transgender adults (27 birth-assigned female) participated in the study. The mean age of participants was 31.01 years (range = 18 to 70). Using an explicit as well as an implicit measure, for the first time, we found that ASD affected gender-related cognition only in autistic cisgender people. Sex differences were also observed in this group. Whereas autistic cisgender birth-assigned males showed a stronger implicit gender-group identification than non-autistic cisgender birth-assigned males, autistic cisgender birth-assigned females showed a weaker gender-group identification than non-autistic cisgender birth-assigned females. Furthermore, autistic cisgender people reported significantly more gender dysphoric feelings and recalled significantly less gender-typed behavior from childhood than non-autistic cisgender individuals. No difference was observed between non-autistic and autistic transgender people. We also found that relative to non-autistic cisgender individuals, both non-autistic transgender and autistic transgender people reported significantly more ASD-like traits. However, mentalizing difficulties were observed only in the latter group. This research enhances our understanding of the link between ASD and gender diversity.