Developing autonomous robots capable of learning complex motions from demonstrations remains a fundamental challenge in robotics. On the one hand, movement primitives (MP) provide a compact and modular representation of continuous trajectories. On the other hand, dynamical systems (DS) provide control policies that are time-independent. In this paper, we propose a simple and flexible approach called MPDS that gathers the advantages of both representations by transforming MPs into autonomous systems. The key idea is to transform the explicit representation of a trajectory to an implicit shape encoded as a distance field. This conversion from a time-dependent motion to a spatial representation enables the construction of an autonomous dynamical system with modular reactions to perturbation. This approach bridges conventional MPs with distance fields, ensuring smooth and precise motion encoding, while maintaining a continuous spatial representation. We use Bernstein basis functions in the MPs to represent trajectories as concatenated quadratic Bézier curves, which provide an analytical method for computing distance fields. By simply leveraging the analytic gradients of the curve and its distance field, a stable dynamical system can be computed to reproduce the demonstrated trajectories while handling perturbations, without requiring a model of the dynamical system to be estimated. Numerical simulations and real-world robotic experiments validate our method's ability to encode complex motion patterns while ensuring trajectory stability, together with the flexibility of designing the desired reaction to perturbations. An interactive project page demonstrating our approach is available at https://idiap.github.io/mp-df-ds/.