If you’ve ever had a shoulder massage or used a foam roller, you’ve likely encountered those small, painful bumps deep in your muscles. Known as myofascial trigger points or muscle knots, these bulges can be tough to ignore once you’re aware of them.

But what exactly are muscle knots, how do they form, and can they cause long-term issues? More importantly, how can you get rid of them?

What Causes Muscle Knots?

Muscle knots typically form when a muscle is overloaded, either through exercise or poor posture. They are most commonly found in the neck, upper trapezius, upper shoulder muscles, mid-back, forearms, and calves.

For example, leaning over a computer for hours a day may not feel like a workout, but it can fatigue your neck, shoulder, back, and forearm muscles, explained Dr. Josh Goldman, associate director of the Center for Sports Medicine at UCLA Health. “Your neck is bent down staring at a computer screen for eight hours,” he said. “That’s a pretty aggressive load on the body.”

When muscles are overtaxed, they can become damaged, causing certain points to shorten or tighten and stay that way. Some researchers believe the surrounding tissue (or fascia) thickens and becomes less elastic, creating a dense ball. This may lead to decreased blood flow and fluid in the area, as well as inflammation.

Why Do They Hurt?

Scientists aren’t entirely sure why some knots hurt and others don’t, or why some hurt only when pressed while others ache all the time, said Christopher DaPrato, a physical therapist at the University of California, San Francisco, who studies chronic pain in athletes.

When they do cause pain, some researchers suspect it may be because of how closely the muscle fibers, fascia, and nerves are packed together. “The body likes space, and when you have these knots, then you have less local space,” Dr. DaPrato said.

Most experts don’t think muscle knots cause irreversible damage to your body, but they can impact your ability to move comfortably and contribute to chronic pain.

How Do You Get Rid of Them?

Many knots will go away on their own after a week or two. However, several treatments can help reduce pain and accelerate healing.

1. Heating Pads and Ice Packs

Studies suggest that both heat and ice can help reduce muscle knot pain. While they won’t break up the knots themselves, heating or ice packs are “almost always useful for symptomatic improvement,” said Dr. Lynn Gerber, a professor emerita at George Mason University who has spent decades studying and treating muscle knots.

2. Stretching

Stretching won’t eradicate knots either, but it can help reduce pain, partly by increasing fluid in the surrounding tissue, which allows everything to “slide and glide” more easily, Dr. DaPrato said. Experts recommend stretching either after exercise, when your muscles are warmed up, or before bed.

3. Massage

Massage can help relieve muscle knot pain and temporarily relax the contractions that cause knots, usually for a day or two. Researchers theorize this has to do with blood flow: When a therapist presses on the tissue around a knot, it restricts blood flow to the area, explained Zachary Gillen, an assistant professor of exercise physiology at Mississippi State University. When the pressure is lifted, blood rushes in, helping the contraction to relax and bringing nutrients to the area.

Self-massage with a lacrosse ball or foam roller can have a similar effect. For knots that impact your quality of life, a physical therapist can perform targeted massage and guide you through strategic exercises.

4. Needling

Dry needling, often performed by a physical therapist or acupuncturist, appears to be among the most effective long-term treatments for muscle knots, Dr. Gerber said. The process involves inserting fine needles directly into knots and removing them after a few minutes. This may be effective because it causes a micro injury to the muscle, prompting a healing response as blood rushes in. It also may work by creating a tiny hole in the knot, Dr. DaPrato said. “When you separate muscle fibers that are too compressed, you’re now creating a little space.”

If all else fails, consider “wet needling,” Dr. Goldman said, which involves injecting a pain medication such as corticosteroids or a numbing agent into the knot. Some doctors have begun injecting botulinum toxin (better known as Botox) into muscle knots, which may temporarily relieve pain by paralyzing the tissue, but Dr. Gerber cautioned that there isn’t much evidence for its long-term effectiveness.

How Do You Prevent Them from Coming Back?

Once you’ve treated your knots, a few habits can prevent them from returning.

First, be mindful of your posture at your desk or on your phone, Dr. Gerber said. You want your eyes to be level with a computer screen or smartphone, and your arms level with a keyboard, so that you’re not craning your neck or hunching at the shoulders.

Next, incorporate regular movement breaks into your day, Dr. Gerber said. Every 20 minutes or so, stand up, stretch, take a lap around your home or office, or do whatever feels good.

Research suggests regular exercise will help too, particularly strength training. “I see the gym and fitness really as the cure for these,” Dr. Goldman said. The stronger and more flexible your muscles are, the less likely they’ll become overtaxed in your day-to-day life.

Finally, remember that there can be too much of a good thing: Pushing yourself too hard at the gym can actually cause knots, Dr. Gillen said. To avoid this, stress your muscles progressively when strength training and gradually ramp up aerobic exercise like running.