Caenorhabditis elegans can generate locomotion under various environments with completely different drag levels. Therefore, animals should have strategies for adapting to the changes in the dynamics of locomotion imposed by various environments. We hypothesized that co-contraction between the ventral and dorsal body wall muscles plays such a role and validated the presence of a co-contraction strategy through both experimental and mathematical modeling approaches. To this end, the fluorescence of calcium ion (Ca2+) corresponding to a part of activities of the body wall muscles were measured. The results indicated a significant difference in the co-fluorescence rate between the animals moving in low- and high-drag environments. The contribution of co-contraction to the dynamics of locomotion was then analysed using a body dynamics model. The simulation results suggested that co-contraction allows the dominance of body stiffness over viscous drag so that the phase difference between the local curvature of the body and muscle activities can be maintained under different environmental drag levels. Therefore, co-contraction can be an effective strategy for adapting to environmental drag that changes the dynamics of locomotion.