Dynamic patient-specific musculoskeletal models have great potential for addressing clinical problems in orthopedics and rehabilitation. However, their predictive capability is limited by how well the underlying kinematic model matches the patient's structure. This study presents a general two-level optimization procedure for tuning any multi-joint kinematic model to a patient's experimental movement data. An outer level optimization modifies the model's parameters (joint position and orientations) while repeated inner level optimizations modify the model's degrees of freedom given the current parameters, with the goal of minimizing errors between model and experimental marker trajectories. The approach is demonstrated by fitting a 27 parameter, three-dimensional, 12 degree-of-freedom lower-extremity kinematic model to synthetic and experimental movement data for isolated joint (hip, knee, and ankle) and gait (full leg) motions. For noiseless synthetic data, the approach successfully recovered the known joint parameters to within an arbitrarily tight tolerance. When noise was added to the synthetic data, root-mean-square (RMS) errors between known and recovered joint parameters were within 10.4° and 10 mm. For experimental data, RMS marker distance errors were reduced by up to 62% compared to methods that estimate joint parameters from anatomical landmarks. Optimized joint parameters found using a loaded full-leg gait motion differed significantly from those found using unloaded individual joint motions. In the future, this approach may facilitate the creation of dynamic patient-specific musculoskeletal models for predictive clinical applications.