Regular nightmares in childhood may be an early warning sign of psychotic disorders, researchers in the UK warn.
The study, in the journal Sleep, said most children had nightmares, but persistent ones may be a sign of something more serious.
Having night terrors - screaming and thrashing limbs while asleep - also heightened the risk.
The charity Young Minds said it was an important study which may help people detect early signs of mental illness. Nearly 6,800 people were followed up to the age of 12.
Parents were regularly asked about any sleep problems in their children and at the end of the study the children were assessed for psychotic experiences such as hallucinations, delusions and thinking their thoughts were being controlled.
The study showed that the majority of children had nightmares at some point, but in 37% of cases, parents reported problems with nightmares for several years in succession.
One in 10 of the children had night terrors, generally between the ages of three and seven.
One theory is that bullying or other traumatic events early in life can cause both symptoms. Or the way some children's brains are wired means the boundaries between what is real and unreal, or sleeping and wakefulness, are less distinct. It means treating the sleep issues may not prevent psychotic events. However, nightmares may act as an early warning sign of future, more serious, problems.
A regular routine and quality sleep were key to tackling nightmares: Sleep hygiene is very important, more regular sleep is required and avoid anxiety-promoting films before bed and not have a computer at night. Night terrors occur at specific points during sleep and can be managed by briefly waking the child.
Lucie Russell, the director of campaigns at Young Minds, said: "This is a very important study because anything that we can do to promote early identification of signs of mental illness is vital to help the thousands of children that suffer. "Early intervention is crucial to help avoid children suffering entrenched mental illness when they reach adulthood.