This paper considers an optimal control problem for a class of controlled hybrid dynamical systems (HDSs) with prescribed switchings. By using Ekeland’s variational principle and a matrix cost functional, a minimum principle for HDSs is derived, which provides a necessary condition of the aforementioned problem. The results given in this paper include both pure continuous systems and pure discrete-time systems as special cases.