  We prove a finite-dimensional moment map property for certain canonical
relatively K\"ahler metrics on holomorphic fibrations, called optimal
symplectic connections. We then relate the existence of zeroes of this moment
map to the stability of the fibration, where the stability property we consider
is a version of K-stability that takes into account the fibration structure,
first introduced by Dervan--Sektnan. In particular, we prove that a stable
deformation of a fibration admitting an optimal symplectic connection still
admits an optimal symplectic connection, through a new approach using the
finite-dimensional moment map properties and the moment map flow.
  We include an appendix with a proof of a result considered by Sz\'ekelyhidi
that a K-polystable deformation of a constant scalar curvature K\"ahler
manifold still admits a constant scalar curvature metric, using the same
technique.
