Flies that cannot keep still when they sleep are helping scientists understand the problem of restless legs syndrome (RLS).
The condition leads to an irresistible urge to move that becomes worse during attempts to rest.
Human studies have highlighted a link between RLS and defective versions of a gene called BTBD9.
Researchers found that fruit flies have a similar gene and when it is not functioning they suffer their own form of RLS.
Flies lacking the gene lost sleep as they kept moving around. When the flies were treated with a drug used for RLS, their sleep improved.
The study also yielded evidence about how the gene works by controlling levels of the brain chemical dopamine, as well as iron balance in cells.
Lead researcher Dr Subhabrata Sanyal, from Emory University in Atlanta, Georgia, said: "Flies and humans are distant from each other on the evolutionary tree, yet the same gene seems to be regulating a fundamental process in both organisms and affecting how soundly they sleep."
The research is published online in the journal Current Biology.