We derive a maximum principle for optimal control problems with constraints given by the coupling of a system of ordinary differential equations and a partial differential equation of Vlasov type with smooth interaction kernel. Such problems arise naturally as Gamma-limits of optimal control problems constrained by ordinary differential equations, modeling, for instance, external interventions on crowd dynamics by means of leaders. We obtain these first-order optimality conditions in the form of Hamiltonian flows in the Wasserstein space of probability measures with forward–backward boundary conditions with respect to the first and second marginals, respectively. In particular, we recover the equations and their solutions by means of a constructive procedure, which can be seen as the mean-field limit of the Pontryagin Maximum Principle applied to the optimal control problem for the discretized density, under a suitable scaling of the adjoint variables.