Find any two people with a diagnosis of depression, and there's more than a fair chance one of them will also experience an anxiety disorder at some point in their life.

While the triggers for each condition are undoubtedly complex, it's clear the genes we inherit can play a strong part in setting us up for a lifetime of bad mental health.

A new study led by researchers from the QIMR Berghofer Medical Research Institute in Australia has now identified 509 genes shared by both psychiatric disorders.

Studies to identify genes associated with mood disorders such as depression and anxiety have uncovered a vast library of candidates in the past. But most of these are like suspects found standing around at the scene of the crime. Little is known about their role in events.

"Not a lot has been known, until now, about the genetic causes of why people may suffer from depression and anxiety," says psychiatric geneticist Eske Derks from QIMR Berghofer.

The term 'anxiety disorders' covers a category of closely related conditions, such as panic disorder and various phobias. The one thing these conditions all have in common is a sense of tension and worry, often accompanied by physiological changes such as an increase in blood pressure.

Depression, on the other hand, is defined by symptoms including low motivation, feelings of sadness and loss of enjoyment, and in extreme cases, thoughts of self-harm.

Roughly 2 to 6 percent of our global community have a diagnosis of depression at any one moment, making it not just a major contributor to poor mental health, but one of the biggest health problems affecting modern society in general. Similarly, anxiety disorders also disrupt the daily lives of hundreds of millions of individuals worldwide. Combined, the two conditions have a significant impact on our species.

Though they can seem like polar opposites in some ways, symptoms of both conditions appear with surprising commonality.

"Both disorders are highly comorbid conditions, with about three-quarters of people with an anxiety disorder also exhibiting symptoms of major depressive disorder," says Derks.

Using genomic data from more than 400,000 participants in the UK Biobank, the research team hunted for an assortment of genes common to both conditions, as well as signs of a personality trait closely related to each – neuroticism.

One of the so-called Big Five personality traits (a handful of fundamental characteristics that consistently define our behaviors and thoughts), neuroticism isn't a disorder in its own right. But having a more neurotic personality does correlate strongly with a tendency towards self-doubt, periods of depression, and a sense of anxiety.

Past research indicates around 40 percent of the variation in neuroticism can be explained by our genes. Many of the same factors happen to overlap with genes already associated with anxiety and depression.

This tells us there's a connection, but to better understand what those factors look like on a physiological level, the research team grouped genomes in the biobank according to a list of 28 individual and shared traits, applying modeling tools to find common factors before identifying associated genes.

Their results were tested against an even larger database of 1.9 million individuals with self-reported symptoms of anxiety and depression, giving them a list of genetic factors that are either likely to be exclusive to either, or common to both.

"We identified 674 genes associated with either depression or anxiety – and importantly about three quarters of those genes were shared," says Derks.

Having a symptom-focused approach opens the way to studying exactly what's putting some of us at greater risk of each condition from a genetic perspective.

For example, some of the genes unique to depression have been previously linked to higher levels of triglyceride fats in the blood, hinting at a metabolic connection in depression that isn't present in anxiety disorders.

"Conversely, our results showed that some of the genes specific to anxiety were related to blood pressure, which is consistent with previous research that has shown a link between the disorder and hypertension," says geneticist and lead author Jackson Thorp.

In an extension to the study, the researchers also traced the locations of the genes to regions that hadn't been linked to either disorder before, providing foundations for whole new collections of genes to study.

Long gone are the days that anybody expects to uncover a single gene responsible for mental health disorders as complex as depression and anxiety.

Even a list of hundreds of sequences won't tell us the full story of why some of us experience chronic low moods, or long periods of intense worry.

But the map connecting the genes we inherit with the mental tools we need to cope with today's increasingly chaotic world is slowly becoming clear, providing opportunities to give so many of us a helping hand when we need it.

This research was published in Nature Human Behaviour.