Aim Prescribing of antidepressant and antipsychotic drugs in general populations has increased in the UK, but prescribing trends in people with type 2 diabetes (T2D) have not previously been investigated. The aim of this study was to describe time trends in annual prevalence of antidepressant and antipsychotic drug prescribing in adult patients with T2D. Methods Repeated annual cross-sectional analyses of a population-based diabetes registry, derived from primary and secondary care data in Scotland, from 2004 to 2021. For each cross-sectional calendar year time period, we calculated the prevalence of antidepressant and antipsychotic drug prescribing, overall and by sociodemographic characteristics and drug subtype. Results The number of patients with a T2D diagnosis in Scotland increased from 161,915 in 2004 to 309,288 in 2021. Prevalence of antidepressant and antipsychotic prescribing in patients with T2D increased markedly between 2004 and 2021 (from 20.0 per 100 person-years to 33.3 per 100 person-years and from 2.8 per 100 person-years to 4.7 per 100 person-years, respectively). We observed this pattern for all drug subtypes except for first-generation antipsychotics, prescribing of which remained largely stable. The degree of increase, as well as overall prevalence of prescribing, differed by age, sex, socioeconomic status, and subtype of drug class. Conclusion There has been a marked increase in the prevalence of antidepressant and antipsychotic prescribing in patients with T2D in Scotland. Further research should identify the reasons for this increase, including indication for use and the extent to which this reflects increases in incident prescribing rather than increased duration.