  In this work we complete the spin-dependent conservative dynamics of
inspiralling compact binaries at the fourth post-Newtonian order, and in
particular the derivation of the next-to-next-to-leading order spin-squared
interaction potential. We derive the physical equations of motion of the
position and the spin from a direct variation of the action. Further, we derive
the quadratic-in-spin Hamiltonians, as well as their expressions in the
center-of-mass frame. We construct the conserved integrals of motion, which
form the Poincar\'e algebra. This construction provided a consistency check for
the validity of our result, which is crucial in particular in the current
absence of another independent derivation of the next-to-next-to-leading order
spin-squared interaction. Finally, we provide here the complete gauge-invariant
relations among the binding energy, angular momentum, and orbital frequency of
an inspiralling binary with generic compact spinning components to the fourth
post-Newtonian order. These high post-Newtonian orders, in particular taking
into account the spins of the binary constituents, will enable to gain more
accurate information on the constituents from even more sensitive
gravitational-wave detections to come.
