K-polystability is, on the one hand, conjecturally equivalent to the existence of certain canonical Kahler metrics on polarised varieties, and, on the other hand, conjecturally gives the correct notion to form moduli. We introduce a notion of stability for families of K-polystable varieties, extending the classical notion of slope stability of a bundle, viewed as a family of K-polystable varieties via the associated projectivisation. We conjecture that this is the correct condition for forming moduli of fibrations. Our main result relates this stability condition to Kahler geometry: we prove that the existence of an optimal symplectic connection implies semistability of the fibration. An optimal symplectic connection is a choice of fibrewise constant scalar curvature Kahler metric, satisfying a certain geometric partial differential equation. We conjecture that the existence of such a connection is equivalent to polystability of the fibration. We prove a finite-dimensional analogue of this conjecture, by describing a GIT problem for fibrations embedded in a fixed projective space, and showing that GIT polystability is equivalent to the existence of a zero of a certain moment map.