The study by researchers at the London School of Hygiene and Tropical Medicine found that young gay and bisexual men are at significantly greater risk of poor mental health than older men in that group.
They were also twice as likely to be depressed or anxious.
The study is the first to examine the mental health differences within gay and bisexual men in the UK.
The researchers analysed responses of 5,799 gay and bisexual men aged 16 and over living in the UK. Depression, anxiety, attempted suicide and self-harm were examined against a range of life factors.
Black gay and bisexual men were twice as likely to be depressed and five times more likely to have attempted suicide than the white majority.
Men in the lower wage bracket were more likely to be depressed, anxious, attempt suicide or self-harm. Those with lower levels of education were twice as likely to experience one of those issues compared to those with degree level education, only in part due to earning a lower wage.
Although more research is needed, the researchers suggest older men are able to cope better with homophobia and that homophobia is more prevalent in the lives of younger men.
"Mental illness is one of the biggest health challenges facing the world today and can affect people from all walks of life," said lead author Ford Hickson from the London School of Hygiene and Tropical Medicine.
"We know minority groups are at higher risk of poor mental health than the heterosexual majority, however the mental health differences within sexual minorities is unclear," Hickson said.
"Our study showed that among gay and bisexual men, age and ethnicity had a significant impact on mental health, as did income and education," he said.
The researchers also discovered cohabitation is key for positive mental health, with men who are living with a male partner 50 per cent less likely to suffer from depression compared to gay and bisexual men living alone.
The study was published in the Journal of Public Health.
