Shipborne multidimensional wave motion compensation devices eliminate the relative motion of cargo between supply and supplied ships. However, the random sway of ships and complicated disturbances still cause various cargo swings. Therefore, an anti-swing control method is proposed that combines deep learning prediction models with a multistate fractional-order terminal sliding mode controller for wave motion compensation devices. First, the constrained workspaces and anti-swing trajectories of cargo based on deep learning prediction models are constructed to decrease the swings of cargo originating from ship sway and inaccurate control parameters. Second, a multistate fractional-order terminal sliding mode controller is presented to eliminate the disturbance-caused cargo swings. Third, the stability of the multistate sliding mode controller is proven. Finally, the effectiveness of the anti-swing control method is verified through simulations and experiments, and the experimental results demonstrate that the maximum amplitude of cargo swings is only a few millimetres and that the maximum mean absolute error of the payload swings is less than four millimetres.