Carpal tunnel syndrome (CTS) has been reported as one of the most common peripheral neuropathies. Carpal tunnel segmentation from magnetic resonance (MR) images is important for the evaluation of CTS. To date, manual segmentation, which is time-consuming and operator dependent, remains the most common approach for the analysis of the carpal tunnel structure. Therefore, we propose a new knowledge-based method for automatic segmentation of the carpal tunnel from MR images. The proposed method first requires the segmentation of the carpal tunnel from the most proximally cross-sectional image. Three anatomical features of the carpal tunnel are detected by watershed and polygonal curve fitting algorithms to automatically initialize a deformable model as close to the carpal tunnel in the given image as possible. The model subsequently deforms toward the tunnel boundary based on image intensity information, shape bending degree, and the geometry constraints of the carpal tunnel. After the deformation process, the carpal tunnel in the most proximal image is segmented and subsequently applied to a contour propagation step to extract the tunnel contours sequentially from the remaining cross-sectional images. MR volumes from 15 subjects were included in the validation experiments. Compared with the ground truth of two experts, our method showed good agreement on tunnel segmentations by an average margin of error within 1 mm and dice similarity coefficient above 0.9.