Scientists say a part of the brain, smaller than a pea, triggers the instinctive feeling that something bad is about to happen.
Writing in the journal PNAS, they suggest the habenula plays a key role in how humans predict, learn from and respond to nasty experiences.
And they question whether hyperactivity in this area is responsible for the pessimism seen in depression.
They are now investigating whether the structure is involved in the condition.
Money or shock
Animal studies have shown that the habenula fires up when subjects expect or experience adverse events, But in humans this tiny structure (less than 3mm in diameter) has proved difficult to see on scans.
Inventing a technique to pinpoint the area, scientists at University College London put 23 people though MRI scanners to monitor their brain activity.
Participants were shown a range of abstract pictures. A few seconds later, the images were linked to either punishment (painful electric shocks), reward (money) or neutral responses.
For some images, a punishment or reward followed each time but for others this varied - leaving people uncertain whether they were going to feel pain or not.
And when people saw pictures associated with shocks the habenula lit up.
And the more certain they were a picture was going to result in a punishment, the stronger and faster the activity in this area.
Scientists suggests the habenula is involved in helping people learn when it is best to stay away from something and may also signal just how bad a nasty event is likely to be.
Dr Jonathan Roiser, a lead author on the paper from University College London, told the BBC:
"Everything that moves needs a system like this - to tell us not to stroke the tiger or go down a dark alley.
"It is likely the habenula is a key neural hub allowing us to anticipate such events."
This area of the brain has been seen to be overactive in animal experiments on depression.
And in one human case-study, providing deep brain stimulation (electrical current) to this area helped reduce depressive symptoms.
Prof Catherine Harmer, at the University of Oxford, who was not involved in the research, said: "This is an important piece of work and has the potential to have great significance in depression.
"If this area is involved in this illness, it may help explain why people suffering from major depression show an over-sensitivity to punishments and are less likely to respond to rewards."
Scientists are now working with people with depression to investigate any differences in brain activity in this area.