Aches and pains on the back of your legs may be a sign of a hamstring injury. Your hamstring is a group of muscles located on the back of your thighs. Strain in these muscles is relatively common, especially in people who play sports that involve sprinting, like soccer, basketball, or track.

Mild hamstring injuries may respond well to rest, over-the-counter (OTC) medications, and ice, but more severe cases may take months to heal.

Read on to learn more about what causes injury to the hamstring, how to get relief from the pain, and when to see your doctor.

The main cause of injury to the hamstring is muscle overload. Strains and tears happen when the muscle is lengthening as it contracts or shortens. They may also happen if the muscle is stretched too far or is taxed too suddenly.

When you sprint, for example, your hamstring muscles must contract repeatedly as your leg lengthens with your stride. All this lengthening and loading of the muscles creates a perfect environment for injury. You may feel anything from sudden pain, to a popping or snapping feeling in your leg. Your hamstring may feel tender and you might even see bruising at the site of your injury.

There are several risk factors for hamstring strain:

  • Exercising with tight muscles. Athletes who have particularly tight muscles may be more likely to experience injury.
  • Muscle imbalances, where certain muscles are stronger than others.
  • Poor conditioning. If the muscles are weak, they’ll be less able to deal with the demands of certain sports or exercises.
  • Fatigue in the muscles, because tired muscles don’t absorb as much energy.

Hamstring strain is commonly seen in people who participate in the following activities:

  • football
  • soccer
  • basketball
  • tennis
  • running and sprinting, and other track events
  • dancing

Older athletes who walk as their primary form of exercise are also at higher risk. So are adolescents whose bodies are still growing. Muscles and bones don’t necessarily grow at the same rate. This means that any force or stress to the muscles, like a jump or impact, may leave them vulnerable to tearing.

If you feel sudden pain in your hamstring, stop what you’re doing to prevent more damage. You may have heard the acronym RICE before. It may help you get better, faster.

RICE stands for:

  • Rest. Avoid doing activities that may aggravate your injury. This may mean totally resting or even using crutches or another mobility aid.
  • Ice. Use a cold pack for 15 to 20 minutes every 2 to 3 hours throughout the day. You may even use something like frozen peas wrapped in a light towel. Don’t apply ice directly to skin.
  • Compression. Consider bandaging your thigh with an elastic wrap to limit swelling and movement.
  • Elevation. Try to keep your leg propped up on a pillow to limit swelling.

OTC pain medications may help ease your discomfort with a hamstring injury. Oral nonsteroidal anti-inflammatory drugs (NSAIDs) like ibuprofen (Motrin, Aleve), or another OTC pain medication like acetaminophen (Tylenol), may be good for short-term relief.

Topical NSAID creams or gels can also help ease pain. If you feel you have injured yourself severely, though, it’s a good idea to see your doctor before self-medicating.

Another option for pain relief involves using a foam roller to apply what’s called myofascial release to your hamstrings. Place the roller just above the back of your knee and roll upward in the direction of blood flow to massage the muscles. Professional sports massage may also help with your pain.

Many hamstring injuries respond well to home treatment and heal within a few days. If your pain isn’t going away or your symptoms are getting worse, it’s a good idea to call your doctor to set up an appointment. In severe cases, your hamstring injury may require surgery and several months of rest and physical therapy.

Regardless of the severity, your doctor can give you important tips on how long you should rest or what exercises might help you prevent future injuries. Your doctor can also refer you to a physical therapist to work on any muscle imbalances that may be contributing to your injuries.

Your recovery will depend on the degree of your strain. A mild or “grade 1” strain heals easily within a few days. A complete tear or “grade 3” strain may take several months to get better.

In some cases, your doctor may ask you to wear a splint for immobilization therapy. This will keep your leg in a neutral position so it can fully rest and heal.

Physical therapy (PT) is another option you may try after your swelling has gone down. In PT, you’ll do different exercises meant to build up your muscles’ range of motion, flexibility, and strength.

You may need surgery to stitch the muscle back in place if you’ve experienced tendon avulsion. An avulsion injury occurs when the tendon tears away from the bone, pulling bone along with it.

Once you’re on the mend, you may use crutches or a brace for some time before beginning a PT program. Your recovery from surgery may take anywhere from three to six months.

Not all hamstring strains can be prevented. You may be in a higher risk group, like an older adult or an adolescent, or experience a sudden impact that causes injury. That said, regular stretching and strengthening exercises may help you lower your risk of hamstring strains. Ask your doctor or coach to suggest specific exercises that may work best for your particular activity.

Following are some general tips for prevention:

  • Warm up before working out or playing sports, and cool down afterward.
  • Exercise regularly to maintain your cardiovascular and muscular fitness. Doing so will help you prevent injuries related to fatigue.
  • Spend time stretching and strengthening muscles in your weekly exercise routine. Doing so will help prevent muscular imbalances that may cause injury.
  • Take days off or have easy days between particularly hard physical sessions to give your body adequate rest.
  • Try adding speed work to your routine to prepare hamstring muscles for the types of forces that may lead to injury.

Hamstring pain can be uncomfortable and sideline you from your favorite sports and other activities. Most cases of strain are likely to ease up in a few days. With some rest, ice, compression, and elevation, you should be back on your feet in no time.

Don’t hesitate to call your doctor if you feel your injury is more serious. The sooner you get help, the sooner you can return to your favorite activities.