Abstract Variable-stiffness joints, with their inherent flexibility, enable highly secure human-robot interactions in unstructured environments. However, existing mechanisms are limited in terms of stiffness regulation flexibility and nonlinear characteristics. This paper proposes a compact variable-stiffness mechanism based on a nonlinear path surface coupled with a permanent magnetic nonlinear spring and a linear spring, namely, PMC-VSA. This mechanism integrates the predictability of the linear spring, the rich magnetic-force nonlinearity of the permanent-magnet spring, and the nonlinear characteristics of the cam profile, thereby enabling arbitrary modulation of the stiffness curve. First, a mechanical model is established to examine how the cam-roller motion alters the linear spring deformation and the permanent-magnet air gap, thus revealing the mechanism of torque and stiffness modulation. Incorporating elastic deformation theory, the relationship between roller rotation angle, output torque, and equivalent stiffness is derived. Further simulation and experimental comparisons, performed by replacing different elastic elements, demonstrate that the proposed mechanism not only enables arbitrary adjustment of nonlinear stiffness but also exhibits superior torque range and response flexibility.