For years, people have turned to melatonin to catch some extra Z's. Now, scientists are discovering it might help quiet another stubborn problem: aches and pains that just won't go away.

A new analysis combining 23 studies found that melatonin modestly reduced chronic muscle and joint pain in more than 2,000 participants. On average, pain scores dropped by about 9 points on a 100-point scale — comparable to some anti-inflammatory medicines in similar research, though the two haven't been directly tested against each other.

Melatonin is a hormone the brain produces naturally at night. It tells your body when it's time to sleep, which is why it's widely used for insomnia and jet lag. But scientists believe it may also calm pain signals in the brain and spine, reduce swelling, and protect cells from damage.

The link between sleep and pain runs both ways. Poor sleep can make pain feel sharper, and pain can make sleep harder to get. The studies in this analysis mostly included people who already struggled with sleep, so it's still unclear whether melatonin works best for poor sleepers or helps everyone equally.

The results were far less impressive for people dealing with pain after surgery. Melatonin made almost no difference — just a tiny 2.5-point drop on the pain scale, which researchers say wouldn't be meaningful for patients recovering from operations.

Melatonin comes in doses ranging from 1 to 10 milligrams in the studies, but researchers couldn't say which amount works best. There's some hint that longer treatment might help more, but the evidence is thin. Side effects can include drowsiness, dizziness, headaches, and nausea, and people with liver or kidney problems or conditions like rheumatoid arthritis should check with a doctor first.

Melatonin is easy to find in U.S. stores as a supplement, but rules differ wildly worldwide. In the United Kingdom, it's available only by prescription and only for short-term sleep troubles. Experts say melatonin shouldn't replace proven treatments like physical therapy, exercise, or anti-inflammatory drugs — but it might one day sit alongside them as an extra tool for certain patients.

More rigorous studies are needed before doctors can say with confidence which people are most likely to benefit.