Background and purpose — There are concerns that mental health (MH) may influence outcomes of total knee arthroplasty (TKA) or total hip arthroplasty (THA). We examined effects of poor MH before surgery on long-term outcomes of osteoarthritis-related TKA or THA in women. Patients and methods — The data were from 9,737 middle-aged participants (47–52 years) and 9,292 older participants (73–78 years) in the Australian Longitudinal Study on Women’s Health who completed surveys between 1998 and 2013. Dates of arthroplasties were obtained from the Australian Orthopaedics Association National Joint Replacement Registry. Participants without procedures were matched with participants with procedures. Trajectories of the Short-Form 36 scores for physical functioning, bodily pain, social functioning, and mental health based on mixed modeling were plotted for participants with and without surgery (stratified according to mental health, separately for TKA and THA, and for middle-aged and older participants). Results — In middle-aged women with poor and good MH, TKA improved physical function and reduced bodily pain, with improvements sustained up to 10 years after surgery. TKA contributed to restoration of social function in women with good MH, but this was less clear in women with poor MH. In both MH groups, mental health appeared to be unaffected by TKA. Similar patterns were observed after THA, and in older women. Interpretation — Recovery of physical and social function and reductions in pain were sustained for up to 10 years after surgery. Improvements in physical function and pain were also observed in women with poor mental health. Thus, in our view poor mental health should not be a contraindication for arthroplasty.