In the first instance it is always recommendable to see a doctor or physiotherapist if you have any concerns about your health as it's difficult to diagnose what the issue might be here from just the information you have given. A doctor may send you for some scans such as MRI or x-rays which would probably show up more clearly what is happening in your leg.
If you have damaged the cartilage in your knee, there will be less fluid between the joints and ligament so you might get friction between the two which will be painful. This would probably coincide with a clicking sound though and you don't mention this. It could be a cramp in your leg caused by muscle tightness but these would normally be in the calf or thigh which would not necessarily cause pain in the knee.
Cramps may be caused by dehydration; minerals and vitamins need water to be transported throughout the body, so try drinking more water. If the pain only comes about after exertion then you should ice the knee and make sure you stretch properly before and after exercise. Check your shoes are properly supportive if you are running and consider doing low impact exercise such as swimming or yoga. You can ask a yoga teacher for asanas that may be particularly useful to knee pain.
If you have damaged the cartilage in your knee, there will be less fluid between the joints and ligament so you might get friction between the two which will be painful. This would probably coincide with a clicking sound though and you don't mention this. It could be a cramp in your leg caused by muscle tightness but these would normally be in the calf or thigh which would not necessarily cause pain in the knee.
Cramps may be caused by dehydration; minerals and vitamins need water to be transported throughout the body, so try drinking more water. If the pain only comes about after exertion then you should ice the knee and make sure you stretch properly before and after exercise. Check your shoes are properly supportive if you are running and consider doing low impact exercise such as swimming or yoga. You can ask a yoga teacher for asanas that may be particularly useful to knee pain.