Objective To examine the association of cognitive function with sex steroid and sex hormone binding globulin (SHBG) levels among elderly men. Design Prospective cohort study, The Osteoporotic Fractures in Men Study (MrOS), consisting of 5995 US community dwelling men of 65 years or older. Patients One thousand six hundred and two men were chosen randomly from MrOS cohort for sex steroid level measurements by Mass Spectrometry (MS) at baseline. Two thousand six hundred and twenty-three MrOS participants with sex steroids measured using RIA were also examined. Measurements Baseline and follow-up (4·5 years later) performance on two cognitive tests: Trails B (executive function and motor speed) and 3MS (global cognitive function). Baseline total testosterone and oestradiol were measured by MS. Free testosterone (free-T) and free oestradiol (free-E) were calculated. SHBG was measured by radioimmunoassay. Data were analysed using linear regression. Results Baseline free-T and free-E levels were not associated with cognitive performance or change in cognition, following adjustment for age, education, race, health status and alcohol use. Baseline SHBG levels were inversely associated with follow-up trails B (P = 0·03) and 3MS performance (P = 0·02). Higher SHBG was associated with an increased risk of cognitive decline. Total sex steroid levels were not associated with cognitive performance. Conclusions Despite large numbers of participants and rigorous sex steroid measurements, we did not observe an association between cognition and either testosterone or oestradiol levels. We conclude that endogenous sex steroids in the normal range are not related to executive function or global cognitive function in elderly men. High SHBG deserves further examination as a risk factor for cognitive decline.