The most likely cause for this is a torn meniscus. If the outer curve of the meniscus is torn, the inner portion can get stuck in the notch or opening for the ligaments. The terms "trick knee" or "locked knee" are used to describe the condition.
Usually the knee can still bend but can't straighten. Sometimes the inner portion of the meniscus can slip back into place. Then the knee seems to work fine again. A minor injury can displace the torn cartilage again.
Most surgeons advise repairing a small tear before another injury tears it completely. Have an orthopedic doctor take a look soon.