This paper proposes a novel mathematical framework for understanding the control mechanisms for fly gaze stabilisation, which is a powerful reflex for achieving a stable gaze by driving the neck motor system using information from different sensors. Our model explicitly considers inherent constraints in biological systems, i.e. the ambiguity and noisiness of sensor signals and inevitable response delays in sensory information processing, and limited energy supply for the neck motor system. The proposed model consists of a state estimator with Kalman filtering and a controller with infinite-horizon dynamic programming that minimises the costs associated with muscle contraction, together with the costs for the fly to be in an imperfectly stabilised state. Closed-loop simulations of the proposed model confirm that our model qualitatively captures the overall properties of the gaze stabilisation system as observed in behavioural experiments. This work will advance our understanding of the fly multisensory gaze stabilisation system and its potential translation into technical applications including autonomous micro air vehicles.