Medicines acting on the central nervous system can increase the risk of postoperative delirium, but the specific medicines associated with greatest risk remain unclear. We aimed to examine the risk of individual central nervous system-acting medicines used preoperatively on delirium after hip or knee surgery. A matched case-control study was conducted using data from the Australian Government Department of Veterans' Affairs. We included people aged 65 years or older who had knee or hip surgery between 2000 and 2019. People with hip or knee surgery who developed postoperative delirium were cases and controls were people with hip or knee surgery but who did not develop postoperative delirium. Use of medicines including anxiolytics, sedatives, and hypnotics, opioid analgesics and antidepressants prior to surgery was compared between cases and controls. A total of 2614 patient cases with postoperative delirium were matched by same sex, age (±2 years), and year of admission (±2 years) with 7842 controls without postoperative delirium. Cases were more likely to be exposed to nitrazepam (odds ratio [OR] = 1.81, 95% confidence interval [CI] 1.24-2.64), sertraline (OR = 1.50, 95% CI 1.20-1.87), mirtazapine (OR = 1.38, 95% CI 1.11-1.74), venlafaxine (OR = 1.42, 95% CI 1.02-1.98), citalopram (OR = 1.54, 95% CI 1.19-1.99), escitalopram (OR = 1.42, 95% CI 1.06-1.89) or fluvoxamine (OR = 5.01, 95% CI 2.15-11.68) prior to surgery than controls. At the class level, exposure to benzodiazepines (OR = 1.20, 95% CI 1.05-1.37) and antidepressants (OR = 1.64, 95% CI 1.47-1.83) prior to surgery was significantly higher in cases than in controls. The numbers needed to treat to harm for one additional delirium case were 43 for sertraline, 40 for citalopram, 57 for mirtazapine and 26 for nitrazepam. Whereas, the numbers needed to treat to harm were found to be 20 for sertraline, 17 for citalopram, 19 for mirtazapine and 10 for nitrazepam in the 85 years or older age group, indicating that the harmful effect of these medicines is pronounced as age advances. People who developed delirium following hip or knee surgery were more likely to be exposed to nitrazepam, sertraline, mirtazapine, venlafaxine, citalopram, escitalopram or fluvoxamine at the time of admission for surgery. Planning to reduce use of these medicines well prior to surgery may decrease the risk of postoperative delirium.