Background: Metformin may have anticancer effects, but its role on prostate cancer remains inconclusive. We thus compared the differences in the risk of prostate cancer between metformin and sulphonylurea users with type 2 diabetes mellitus (T2DM). Methods: This retrospective cohort study included male patients with T2DM attending public hospitals/clinics in Hong Kong between 1 Jan 2000 and 31 Dec 2009 as recorded by a local territory-wide clinical database that captures key demographic, clinical and medication records of all patients attending public healthcare services in Hong Kong. All patients were followed up till 31 Dec 2019. The outcome of interest was prostate cancer. We excluded patients with baseline age <18 years old, prior diagnoses of cancer, prescriptions of both metformin and sulphonylurea or neither. 1:1 propensity score matching was performed based on demographics, Charlson comorbidity index, past comorbidities, non-metformin/sulphonylurea medications, anti-diabetic and cardiovascular medications, and HbA1c. Results: Screening of the clinical database using the inclusion and exclusion criteria identified 67471 male patients who were eligible for matching. Propensity score matching matched 26109 metformin users in a 1:1 ratio to sulfonylurea users, producing a final cohort of 52218 male patients (mean age 68.6±12.1 years, mean follow-up 9.3±3.5 years). Prostate cancer occurred in 382 metformin users (crude rate: 1.46%) and 1154 sulphonylurea users (crude rate: 4.41%). Cox regression analysis demonstrated that metformin users had lower risks of prostate cancer than sulfonylurea users (hazard ratio 0.32, 95% confidence interval [0.29, 0.36], p<0.0001). Conclusion: Metformin use, compared to sulphonylurea use, was associated with lower risks of prostate cancer in patients with T2DM. This study highlights the importance of pharmaceutical choice for patients with T2DM at high risks of prostate cancer.